I have two sheets.
sheet1 and sheet2.
I have my data in sheet2. The sheet1 already contains data until 4th row.
I would like to copy all the data in sheet2, from row5 to sheet 1 after the 4th row.
I tried the below code. but each time I run the code. it is getting copied randomly in 114 row or sometimes in 1000th row.
here is the code , I am using to copy.
Sub FClookup()
Dim LastRow As Long
'get last row
LastRow = Worksheets("Sheet1").Cells(Rows.count, 1).End(xlUp).Row
Worksheets("Sheet2").Range("A5:W1000").Copy _
Destination:=Worksheets("Sheet1").Range("A" & LastRow + 1)
End Sub
The following should do what you're looking for. The code is assuming that Column A in Sheet2 is always filled and will copy all the data from Columns A to D from Sheet2 to the next free Row in Sheet1 (checking column A).
Option Explicit
Sub CopyStuff()
Dim ws1, ws2 As Worksheet
Set ws1 = Worksheets("Sheet1")
Set ws2 = Worksheets("Sheet2")
ws2.Range("A5:D" & ws2.Range("A5").End(xlDown).Row).Copy
ws1.Range("A" & ws1.Range("A1").End(xlDown).Row + 1).PasteSpecial xlValues
End Sub
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments