Results 1 to 4 of 4

Code not working - move rows when cell is less than zero

Threaded View

  1. #1
    Registered User
    Join Date
    11-12-2009
    Location
    surrey
    MS-Off Ver
    Excel 2003
    Posts
    22

    Question Code not working - move rows when cell is less than zero

    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
    Last edited by wishmaker; 09-01-2011 at 10:33 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1