+ Reply to Thread
Results 1 to 10 of 10

Delete empty rows

  1. #1
    Registered User
    Join Date
    07-02-2012
    Location
    dhaka
    MS-Off Ver
    Excel 2007
    Posts
    5

    Delete empty rows

    Hi all,

    Pls take a look at the following excel file: (- represents blank cell that may contain formulas)
    Cell Cell
    A B
    1 -
    1 -
    1 -
    - 1
    - -
    1 1

    Now, I want to delete those rows which has only all the rows blank (that includes formulas that returns nothing), when I click on my mouse to the sheet (say sheet1).


    Is it possible to do so?


    Thanks in advance.

    In Dhaka

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: Delete empty rows

    Hi InDhaka,

    Welcome to the forum.

    1-
    -1
    would not be deleted right?

    and basis your data only one row i.e,
    - -
    would be deleted.. right?

    Regards,
    DILIPandey

    <click on below 'star' if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

  3. #3
    Registered User
    Join Date
    07-02-2012
    Location
    dhaka
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Delete empty rows

    Hi there!

    Thats Correct. Thanks for asking.

    1 - ......
    - 1 ......
    - - - - -
    1 1 ......
    - - 1 1 1

    Only the 3rd row will be fully deleted when I click on the sheet. The blank cells may contain formulas!

    ID

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

    Re: Delete empty rows

    How about using a helper column at the end of the row and if equal to nothing then filter that row to show the empty rows and delete visible cells.
    HTH
    Regards, Jeff

  5. #5
    Registered User
    Join Date
    07-02-2012
    Location
    dhaka
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Delete empty rows

    Hi there!

    Thanks. I thought about that.

    But I was trying to find a VBA solution to spare from that.

    By the way, there would be two such ranges in my excel sheet. And using a for loop is not the option, as each time the cell is activated, it starts working on a new range!

    BR,ID

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

    Re: Delete empty rows

    Quote Originally Posted by indhaka View Post
    By the way, there would be two such ranges in my excel sheet.
    It seems like the requirement always grow in one way or another.

    With the method I suggested it could easily be worked into a VBA solution, but since you now say there are two ranges, do you want to provide a working sample?

  7. #7
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete empty rows

    Hi indhaka,

    Though trying to keep null formulas complicates things, try this (initially on a copy of your data as the results cannot be undone if they're not as expected) while on the sheet in question:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  8. #8
    Registered User
    Join Date
    07-02-2012
    Location
    dhaka
    MS-Off Ver
    Excel 2007
    Posts
    5

    Cool Re: Delete empty rows

    Hi again.

    Thanks a lot to both you!

    Yes, you rightly pointed out, the requirements do keep growing!!

    But on second thought, its not an issue! Let me try to re articulate the problem bit better this time.

    If I put an additional row, thats hidden but keep tracks of whether the rows in a range are empty or not, it also takes care of cells without value but formulas buried inside (I need them to be deleted!)

    By the way, pal, I tried to run the code, but things dont seem to be working! No change! Btw, I am not a veteran excel programmer. So,need more hand-holding!!

    I am attaching the file if I am not clear still.

    Thanks again folks!

    I can feel I am getting closer to a solution.

    NB. In the attachment I am just trying to delete the rows that are blank on Column A whenever I select the sheet.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    07-02-2012
    Location
    dhaka
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Delete empty rows

    Btw, if sheet activation is not possible, can I invoke a macro command using a formula?
    In that case, using a filter as suggested above may solve my case.

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

    Re: Delete empty rows

    With your test file, remove the two calculations columns (A & B) and then run 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