Cut bottom 300 rows to next sheet & repeat
if it should be not exceeding the column "O"
Sub ThreeHund()
Dim wks1 As Worksheet, wks2 As Worksheet
Dim iColumn As Integer
Dim lLast As Long
Dim i As Long, j As Integer, y As Integer
Set wks1 = Worksheets("Dum")
Set wks2 = Worksheets("Mud")
lLast = wks1.Cells(wks1.Rows.Count, 1).End(xlUp).Row
For iColumn = 2 To 3
lLast = Application.Max(lLast, wks1.Cells(wks1.Rows.Count,
iColumn).End(xlUp).Row)
Next iColumn
If lLast < 300 Then
MsgBox "Less than 300 rows", vbOKOnly
Exit Sub
End If
For i = 300 To lLast Step 300
y = y + 1
j = wks2.Cells(1, wks2.Columns.Count).End(xlToLeft).Column + 1
wks1.Range("A" & i & ":C" & i + 299).Copy wks2.Cells(1, j)
If y = 5 Then wks2.Range("A:A").Delete Shift:=xlToLeft: Exit Sub
Next
Set wks1 = Nothing
Set wks2 = Nothing
End Sub
isabelle
|