+ Reply to Thread
Results 1 to 15 of 15

Macro to delete blank rows with formulas

  1. #1
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Macro to delete blank rows with formulas

    Hello, thanks up front for any assistance. I have a macro working well for a report that needs a couple of tweaks, including what I am asking for here. To accommodate reports of up to about 2000 lines of data, formulas are included up to row (approx) 2000. After running the macro, I have to manually delete additional rows to avoid printing a few hundred pages. The challenge is, some reports contain a blank row of data, so I cannot find the first blank line and delete the rest.

    In this case, am thinking we could find two blank rows in a row, and delete from there. Reason being, the report is split into sections based on a "rating", and if one or more people are not "rated", the row above that section (group of people not rated) is blank.

    Any idea on how to best select the remaining blank rows and delete them from the report so they are not included in printing?

    Thanks as always, appreciate the assistance.
    Sheryl

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to delete blank rows with formulas

    You do not need to delete any rows.
    Let's say your report has 2000 rows of data and formulas but only 100 contain actual data.
    You can add before print event that hives all rows where the formula value is blank, print and after that restore the hidden rows.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to delete blank rows with formulas

    Hi, thanks so much for the quick response. What does adding before a print event mean?

    Thanks!

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to delete blank rows with formulas

    Google is my best friend, you should try it

    below are two links to help you on the way...

    https://msdn.microsoft.com/en-us/lib...ffice.11).aspx
    http://www.mrexcel.com/forum/excel-q...int-event.html

  5. #5
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to delete blank rows with formulas

    It is good to have friends, even if it's Google. I did of course search, which led me here. Thanks for your help.
    Sheryl

  6. #6
    Registered User
    Join Date
    11-21-2016
    Location
    Emmen, The Netherlands
    MS-Off Ver
    MS Office 365 ProPlus
    Posts
    19

    Re: Macro to delete blank rows with formulas

    Hi Sheryl,

    Would an extra column with a filter do the trick?
    See attachment.

    Or do you need to do this with VBA?


    Ton.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to delete blank rows with formulas

    I'm going off-line now so I haven't looked at your file but if you use an extra column and apply the filter manually before printing, it will work too since only the visible rows will be printed by default.
    In that case you do not need vba.

  8. #8
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to delete blank rows with formulas

    Hi All, thanks for the responses, all helpful. VBA is preferred in this case because this type of report is associated with high volume reporting, so we try and include as much as possible within the macro. Not the biggest deal to remove the added lines but because prefer to have it deleted automatically.

    Is this too complex?

    Thanks again for any help.
    Sheryl

  9. #9
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to delete blank rows with formulas

    Hi Sheryl,
    Does this mean that once the report has been printed no new data will be added?
    In this case, instead of hiding the rows, you can let the macro delete them.

  10. #10
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to delete blank rows with formulas

    Hi Keebellah, yes, that is correct, and I am looking to have the macro delete those rows. My challenge is, finding the last row will not always work because there could be one blank row before the rows of data end. Within the macro, additional lines are added to break out sections of "ratings" however not everyone will have a rating, and therefore a blank line is inserted for those without a rating as well.

    Therefore, I need to find the second blank row, or find two blank rows in a row to determine where to start deleting. This is where I got stuck with VBA. Any thoughts?

    Thanks.

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to delete blank rows with formulas

    Maybe?

    Please Login or Register  to view this content.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Macro to delete blank rows with formulas

    Hi I just got in and yes @John's idea is what I was thinking too.
    I generally don't work with arrays but it's the same idea.
    From bottom (last filled row) up

  13. #13
    Forum Contributor
    Join Date
    08-08-2015
    Location
    NJ
    MS-Off Ver
    2013
    Posts
    205

    Re: Macro to delete blank rows with formulas

    Thank you!!! I think this can do the trick!

    Best, Sheryl

  14. #14
    Registered User
    Join Date
    10-07-2015
    Location
    lansing,mi
    MS-Off Ver
    10
    Posts
    5

    Re: Macro to delete blank rows with formulas

    I realize that this is an older sub...

    John's VB works but is there a way to apply it to all of the worksheets?

  15. #15
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Macro to delete blank rows with formulas

    Welcome to the Forum. It's best to post a new thread when you need help. This being an older thread other folks might hesitate to read or help. You can always reference this thread in the new one by copying and posting the link. Anyway try this:

    Please Login or Register  to view this content.
    I'm sure that your ranges are a bit different though. If you can be more specific as to what you want to achieve maybe we can help your further.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need Macro to delete all blank rows
    By caanilsoni in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-13-2015, 12:59 AM
  2. Macro to delete blank rows if column I is blank for the row
    By tiger10012 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2013, 03:01 PM
  3. Macro to Delete Blank Rows
    By smlaff01 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2007, 02:37 PM
  4. Macro to delete row if row blank but cells do have formulas in the
    By Cathy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-15-2006, 08:10 PM
  5. [SOLVED] Delete blank rows Macro
    By Richard in forum Excel General
    Replies: 3
    Last Post: 11-04-2005, 04:10 AM
  6. Using a macro to delete all blank rows
    By Shirley Munro in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-18-2005, 04:05 AM
  7. Macro to delete blank rows
    By Barb Reinhardt in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-15-2005, 06:05 PM

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