+ Reply to Thread
Results 1 to 8 of 8

Selectively deleting all/each rows in a sheet based on a specific criterion (how?)

  1. #1
    Registered User
    Join Date
    06-13-2007
    Location
    San Diego, CA
    Posts
    9

    Selectively deleting all/each rows in a sheet based on a specific criterion (how?)

    1st timer here - I hope the question isn't a waste.

    What I’m working with:
    I made a report that uses lookup functions to populate it's rows with text descriptions from a XLS database based on a specific initial criterion entered in one cell.
    If every row had the description listed this report would be about seven pages long printed. But, no report uses all the potential row descriptions.
    I now need to create about 1000 reports…and the idea of deleting the ‘blank’ rows manually seems very daunting, if not prone to error.

    The goal:
    To ‘automatically’ delete each row that does not fill itself out with row's description according to the logic of the lookup function, i.e., the ‘blank’ (unused) rows.

    The question:
    Is it possible to define a macro (?) to read whether (for example) the third cell of each row contains a (-) sign and nothing else in the next cell to the right (same row), then to delete the entire row from the workbook?

    Any help or suggestions for direction are much appreciated!

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Try

    Please Login or Register  to view this content.
    Last edited by mrice; 06-19-2007 at 05:42 PM.
    Martin

  3. #3
    Registered User
    Join Date
    06-13-2007
    Location
    San Diego, CA
    Posts
    9

    thanks..?

    I'm sure this must seem painfully obvious to you but is that code for a macro or...? I.e., how would I use it? Thank you!

  4. #4
    Registered User
    Join Date
    06-13-2007
    Location
    San Diego, CA
    Posts
    9

    example

    here is a partial of that report without the underlying formulas (to keep it small). I hope this better illustrates my puzzle. I highlighted the rows that the formulas did not fill when the address was given in the first cell - these are what I'd like to erase by using a ?? macro?
    Attached Files Attached Files

  5. #5
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    OK..
    Hit Alt F11 to get into the VBA editor
    Right click in the project explorer window on the left and insert a new module.
    Paste the macro into the blank page
    Hit Alt F11 to get back to the workbook.
    Select the area containing the cells of interest.
    On the menu bar hit Tools - macro - macros and select Test.
    Hit the run button.

  6. #6
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967
    Your sheet has the dashes in column B so the code will need to be amended as follows

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    06-13-2007
    Location
    San Diego, CA
    Posts
    9

    Yeah!

    Thank you! works like a charm

  8. #8
    Registered User
    Join Date
    06-13-2007
    Location
    San Diego, CA
    Posts
    9

    can this be selectively applied?

    Is there a way to specify that the macro (thanks Martin) run on specific rows, thereby avoiding the need to run on the entire (and quite large) worksheet?

    Ideally I'd like the code to have, written within it, the ability to act on specific rows.

    Any ideas? Thanks!

+ 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