+ Reply to Thread
Results 1 to 4 of 4

Delete rows where value < 100,000

Hybrid View

  1. #1
    Registered User
    Join Date
    10-23-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    5

    Delete rows where value < 100,000

    Hi,

    I am writing a macro where I need to delete all rows below a certain value, in this case 100,000.
    As you can see in the (simplified) example, I have a column with names and numbers. So all the rows where the value in column B is smaller than 100,000 need to be deleted. But 100,000 can occur multiple times.
    So in this case everything from row 9 and down should be deleted. The rows are sorted so there can't be a value greater than 100,000 below row 9.
    If possible, I would like to do it without iterating through all the rows and checking each value.

    Can anyone help me with this? Your help would be greatly appreciated.
    Attached Files Attached Files
    Last edited by Smos; 11-06-2011 at 09:46 PM.

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Delete rows where value < 100,000

    Hello & Welcome to the Board,

    Try...

    Sub FilterDelete()
        With Range("B1", Range("B" & Rows.Count).End(xlUp))
            .AutoFilter Field:=1, Criteria1:="<100,000"
            .Offset(1).Resize(.Rows.Count - 1).EntireRow.Delete
            .AutoFilter
        End With
    End Sub
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    10-23-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Delete rows where value < 100,000

    Worked like a charm.
    Thank you so much!

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Delete rows where value < 100,000

    You're very welcome

+ Reply to Thread

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