abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,429
- Office Version
- 2019
- 2010
- Platform
- Windows
hi
I have this code copy data from sheet to another what I want after copy data to sheet 2 when reach to last row is 1000 it moves automatically to next sheet is sheet3 and start the data from row 2 as in sheet2 .the same thing when the data reaches in sheet3 in lastrow 1000 then should move to next sheet4 and so on
the restrict depends on lastrow(1000) . the data begins from A1: D as in my code .
I hope my thread is logic .
I have this code copy data from sheet to another what I want after copy data to sheet 2 when reach to last row is 1000 it moves automatically to next sheet is sheet3 and start the data from row 2 as in sheet2 .the same thing when the data reaches in sheet3 in lastrow 1000 then should move to next sheet4 and so on
the restrict depends on lastrow(1000) . the data begins from A1: D as in my code .
VBA Code:
Sub CopyData()
Dim LastRow As Long, d As Long
Dim CopyRange As Range, count As Long
With Sheets("sheet1")
LastRow = .Cells(.Rows.count, "A").End(xlUp).Row
For d = LastRow To 10 Step -1
If .Cells(d, "A") = Date - 1 Or .Cells(d, "A").Value = Date Then
count = count + 1
If CopyRange Is Nothing Then
Set CopyRange = .Rows(d).EntireRow
Else
Set CopyRange = Union(CopyRange, .Rows(d).EntireRow)
End If
End If
Next d
End With
CopyRange.Copy Sheets("sheet2").Range("A3")
End Sub
I hope my thread is logic .