Hi,
I'm new to using macros in excel, so please forgive me for my lack of knowledge or if I'm doing something completely wrong.
I am trying to move cells that auto-populate from specific areas on a source sheet (CIP), to corresponding specific areas on a master log target sheet (CIP 2024). It also needs to find the next empty space in correct area on the target sheet and paste the data there.
The code I have written sort of works...except instead of moving it to column AJ row 4, in the target sheet, it moves to column A and all the way down to rows in the 900s.
Any help is greatly appreciated.
Here is my code thus far:
I'm new to using macros in excel, so please forgive me for my lack of knowledge or if I'm doing something completely wrong.
I am trying to move cells that auto-populate from specific areas on a source sheet (CIP), to corresponding specific areas on a master log target sheet (CIP 2024). It also needs to find the next empty space in correct area on the target sheet and paste the data there.
The code I have written sort of works...except instead of moving it to column AJ row 4, in the target sheet, it moves to column A and all the way down to rows in the 900s.
Any help is greatly appreciated.
Here is my code thus far:
VBA Code:
Sub CopyDataToAnotherSheet()
Dim sourceSheet As Worksheet
Dim targetSheet As Worksheet
Dim BTR2 As Range
Dim lastRow As Long
Set sourceSheet = ThisWorkbook.Sheets("CIPs")
Set targetSheet = ThisWorkbook.Sheets("CIP 2024")
Set BTR2 = sourceSheet.Range("U23:Y38")
lastRow = targetSheet.Cells(targetSheet.Rows.Count, "AJ").End(xlUp).Row
BTR2.Copy
targetSheet.Cells(lastRow, 1).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub