+ Reply to Thread
Results 1 to 4 of 4

Excel doesn't think blank cells are not really blank?

  1. #1
    Registered User
    Join Date
    07-27-2007
    Posts
    7

    Excel doesn't think blank cells are not really blank?

    Here is a peculiar problem:

    I have a macro, which copies a table to a new worksheet and pastes all as values. I then need to delete the rows, which contain one or more missing values (i.e. rows containing blank cells.). However, when I use this excellent macro:

    Sub DeleteBlankRows2()
    'Deletes the entire row within the selection if_
    some of the cells WITHIN THE SELECTION contain no data.
    On Error Resume Next
    Selection.EntireRow.SpecialCells(xlBlanks).EntireRow.Delete
    On Error GoTo 0
    End Sub

    or use the GoTo Blanks Cells function, nothing happens. Excel does not seem to think that the blank cells are actual blank. But after having pressed delete in a blank cell, then that cell is accepted as blank.

    What do I do about that? Has anyone ever experienced this?

    Thank for your help!

    Leon

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,808
    This problem does creep up here frequently in one form or another.

    the xlblanks special cell refers to a cell if and only if that cell contains Nothing. A cell that contains an empty string ("") or a space (" ") may look empty, but it still contains something. A cell that contains a formula that returns an empty string [=if(iserror(a1),"",a1)] contains something and will not be included in the collection of blank cells.

    What you need to do is go back to your spreadsheets and determine what those "blank" cells contain, so you can modify that macro to search for those cells.

  3. #3
    Registered User
    Join Date
    07-27-2007
    Posts
    7
    Thanks a lot for your reply! I did not know that.

    So, the formulas that return the blank cells actually return "". Do you know by any chance how I could change the macro above to search for that instead?

    Thanks again!

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,808
    This may not be syntactically correct, so adjust as needed, but something along the lines of:
    Please Login or Register  to view this content.
    As noted, that code probably needs a little more work to get it to work properly, but it should give you the idea.

+ 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