Craigeeh22
New Member
- Joined
- Sep 11, 2008
- Messages
- 15
Hi
I have a quick easy question i have this code which works fine on my worksheet but i need it to look down the whole Coloum of R(i have highlighted below) at the moment it looks down the list and as soon as there is a gap it stops?? for example
ColoumR
Complete
Complete This will copy to other worksheet
Complete
Complete these wont copy due to gap????
Complete
Sub MoveRows()
Dim rngOrigin As Range, rngDest As Range
Dim i, j As Integer
i = 1: j = 1
Set rngOrigin = Sheets("Sheet1").Range("R2")
Set rngDest = Sheets("Sheet2").Range("A1").Offset(Application.WorksheetFunction.CountA(Sheets("Sheet2").Range("A:A")))
Do While rngOrigin.Offset(i, 0).Value <> ""
If rngOrigin.Offset(i, 0).Value = "Complete" Then
rngOrigin.Offset(i, 0).EntireRow.Copy
Sheets("Sheet2").Activate
rngDest.Offset(j, 0).Select
ActiveSheet.Paste
Sheets("Sheet1").Activate
rngOrigin.Offset(i, 0).EntireRow.Delete xlShiftUp
j = j + 1
i = i - 1
End If
i = i + 1
Loop
Application.CutCopyMode = False
End Sub
Thank you if you can help??
I have a quick easy question i have this code which works fine on my worksheet but i need it to look down the whole Coloum of R(i have highlighted below) at the moment it looks down the list and as soon as there is a gap it stops?? for example
ColoumR
Complete
Complete This will copy to other worksheet
Complete
Complete these wont copy due to gap????
Complete
Sub MoveRows()
Dim rngOrigin As Range, rngDest As Range
Dim i, j As Integer
i = 1: j = 1
Set rngOrigin = Sheets("Sheet1").Range("R2")
Set rngDest = Sheets("Sheet2").Range("A1").Offset(Application.WorksheetFunction.CountA(Sheets("Sheet2").Range("A:A")))
Do While rngOrigin.Offset(i, 0).Value <> ""
If rngOrigin.Offset(i, 0).Value = "Complete" Then
rngOrigin.Offset(i, 0).EntireRow.Copy
Sheets("Sheet2").Activate
rngDest.Offset(j, 0).Select
ActiveSheet.Paste
Sheets("Sheet1").Activate
rngOrigin.Offset(i, 0).EntireRow.Delete xlShiftUp
j = j + 1
i = i - 1
End If
i = i + 1
Loop
Application.CutCopyMode = False
End Sub
Thank you if you can help??