0
votes

I'm trying to find the last row off column D, then move three up, and one to the right and insert data to that column.

The reason for this, is that the above cells are dynamic and can be deleted and added as you go along - the last cell and the cell I'm trying to target, doesn't contain the same reference (except from the last line in any column, which are always three down and one to the right from D (LastRow).

I haven't found a solution in similar posts.

The image shows the sheet.
The cells marked with yellow are the lastRow cell and the cell I'm trying to insert data into.
The cells marked with a blue ring, contains the dynamic cells, which gets longer/shorter depending on the situation.

Sheet I'm working on

2
Take a look at this answer to find the last used cell in a column.Tom Brunberg
Thank you for the reply - Allthough i've seen the thread, but the solutions seemed complicated for what i needed (Maybe I just didn't understand them properbly) - I solved it by using the code in my comment below (Y)MNDevelopments

2 Answers

1
votes

You may convert that to one line rather than multiple lines.

Dim korrektion1 As Double
Private Sub CommandButton1_Click()
Range("E4").End(xlDown).Offset(-3, 0).Value = korrektion1
Unload UserForm2
End Sub
1
votes

I ended up solving my problem with the following code:

Dim korrektion1 As Double
Private Sub CommandButton1_Click()

Range("E4").End(xlDown).Select

Selection.Offset(-3, 0).Select

Selection.Value = korrektion1

Unload UserForm2

End Sub