+ Reply to Thread
Results 1 to 4 of 4

Delete Row when value inside cell is less than 0

  1. #1
    Registered User
    Join Date
    04-28-2006
    Posts
    14

    Delete Row when value inside cell is less than 0

    I was taught by a friend how to delete a row when a cell is blank with this script:

    Sub DeleteBlankRows_1()
    'This macro delete all rows with a blank cell in column A
    On Error Resume Next 'In case there are no blank cells
    Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0
    End Sub

    but my problem is that I do not care for blank cells, I am only concerned with a cell who has a value that is not greater than 0. It could be blank, it could be equal to 0, or it could be something like #REF! and #DIV/0!...somebody please Help!!!!

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    To delete rows with #REF! and #DIV/0! in them you can use this statement

    Columns("A").SpecialCells(xlCellTypeFormulas, 16).EntireRow.Delete


    Quote Originally Posted by bm4466
    I was taught by a friend how to delete a row when a cell is blank with this script:

    Sub DeleteBlankRows_1()
    'This macro delete all rows with a blank cell in column A
    On Error Resume Next 'In case there are no blank cells
    Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    On Error GoTo 0
    End Sub

    but my problem is that I do not care for blank cells, I am only concerned with a cell who has a value that is not greater than 0. It could be blank, it could be equal to 0, or it could be something like #REF! and #DIV/0!...somebody please Help!!!!
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

  3. #3
    Registered User
    Join Date
    04-28-2006
    Posts
    14
    Thanks a lot...do you know how to do it when the value is less than or equal to 0?

  4. #4
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    Quote Originally Posted by bm4466
    Thanks a lot...do you know how to do it when the value is less than or equal to 0?

    The only way I know is to loop through each value and test it like this

    Please Login or Register  to view this content.

+ 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