+ Reply to Thread
Results 1 to 9 of 9

Writing a macro that deletes blank rows

  1. #1
    Registered User
    Join Date
    10-15-2008
    Location
    Alabama
    Posts
    25

    Writing a macro that deletes blank rows

    I need help writing a macro. I only have experience recording them, not writing them in VBA.

    I need to check columns A and B for blanks. If A and B are both blank, I want the macro to delete the row and move on to check the next row. I need to perform this macro for the entire worksheet.

    Thanks in advance for the help.
    Last edited by britt@wjg; 12-11-2008 at 01:01 PM. Reason: solved

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-15-2008
    Location
    Alabama
    Posts
    25
    My sheet is about 10,000 lines. Is this too large for the macro to run? I tried a couple times to run it and it took about 3 minutes then Excel gave me the "Not Responding" message.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I should think it is the size of the range

  5. #5
    Registered User
    Join Date
    12-11-2008
    Location
    Southern California
    Posts
    13
    Hi,

    Rather than create a new topic, I am posting my question in here as it is related.

    In a sheet titled "WH", I have a column in which I designate each row with either a "W" or and "S". I need the macro to search all the rows with "S" and delete these rows. Also, this macro needs to work for any sets of data, independent of the number of rows a specific set may have.

    Thanks in advance for your help!

  6. #6
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    Try this version:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    12-11-2008
    Location
    Southern California
    Posts
    13
    mdbct,

    The column I need the macro to look at is column B. Sorry for not making that clear initially. Does the code you provided need to be modified in any way so that the macro knows what column to look at?

    Thanks.

  8. #8
    Valued Forum Contributor mdbct's Avatar
    Join Date
    11-11-2005
    Location
    CT
    MS-Off Ver
    2003 & 2007
    Posts
    848
    JHCali,
    My response was to the original poster's question, not yours. You should have started a new post for your question. This thread has been marked as "solved" and could be skipped over by "the solvers" since they would think there is now longer an issue.

    I've highlighted the line that checks the B column for the lettere S being present

    Please Login or Register  to view this content.
    Last edited by mdbct; 12-11-2008 at 02:21 PM.

  9. #9
    Registered User
    Join Date
    12-11-2008
    Location
    Southern California
    Posts
    13
    Mdbct,

    Rookie poster mistake. Thanks for the heads up. But moreover, thanks for your help. Your code worked perfectly!

+ 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