Hi all,
I am really struggling with this, and it's something I worked out in the past but for the life of me cannot work it out again!
I have two worksheets. ws = "Crime" and ws1 = "Log".
In worksheet "Log", in cell "A1" I have typed in "Log No" (which is permanent)
What I am trying to do is when I click a button in "Crime", it finds the next empty cell in Row 1 in "Log" and copies and pastes the value from cell "B2" from worksheet "Crime".
I have tried this code but for some reason inserts the copied value into A11!
Sub Last_Cell()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
'Set variables for copy and destination sheets
Set wsCopy = Sheets("Crime")
Set wsDest = Sheets("Log")
lDestLastRow = wsDest.Cells(1, "A").End(xlUp).Offset(0, 1).Row
wsDest.Range("A1" & lDestLastRow).Value = wsCopy.Range("B2")
End Sub
Obviously, I am doing something wrong so any help would be gratefully appreciated.
Many thanks.
M
I am really struggling with this, and it's something I worked out in the past but for the life of me cannot work it out again!
I have two worksheets. ws = "Crime" and ws1 = "Log".
In worksheet "Log", in cell "A1" I have typed in "Log No" (which is permanent)
What I am trying to do is when I click a button in "Crime", it finds the next empty cell in Row 1 in "Log" and copies and pastes the value from cell "B2" from worksheet "Crime".
I have tried this code but for some reason inserts the copied value into A11!
Sub Last_Cell()
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
'Set variables for copy and destination sheets
Set wsCopy = Sheets("Crime")
Set wsDest = Sheets("Log")
lDestLastRow = wsDest.Cells(1, "A").End(xlUp).Offset(0, 1).Row
wsDest.Range("A1" & lDestLastRow).Value = wsCopy.Range("B2")
End Sub
Obviously, I am doing something wrong so any help would be gratefully appreciated.
Many thanks.
M