Code updated with friends suggestion...
Range("BU2").Select
Do Until Selection.Value = ""
If Range("BU2").Value <= 0# Then
Rows("2:2").Copy
Sheets("Queries").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Sheets("Just Giving").Select
Application.CutCopyMode = False
Selection.EntireRow.Delete
Range("Bu2").Select
Else
Selection.Offset(1, 0).Select
End If
Loop
------------------------------------------------------------------
I have been using the following code for last 2 years and it's worked fine. But I can't understand why it no longer works.
Some background: I have a payment file with two sheets (Queires & Just Giving) the code is supposed to move any rows to the Queries sheet when the payment cell (BU2) is equal to or less than zero (<=)
Range("BU2").Select
Selection.Sort Key1:=Range("BU2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("BU2").Select 'BU
Do While Selection.Value > 0
If Range("BU2").Value <= 0 Then 'BU
Rows("1:1").Copy
Sheets("Queries").Select
Rows("1:1").Select
Selection.Insert Shift:=xlDown
Application.CutCopyMode = False
Sheets("Just Giving").Select
Application.CutCopyMode = False
Selection.EntireRow.Delete
Range("Bu2").Select 'BU
Else
Selection.Offset(1, 0).Select
End If
Loop
Bookmarks