+ Reply to Thread
Results 1 to 6 of 6

I need a macro that will automatically hide a row when the sum of a row = 0

  1. #1
    Registered User
    Join Date
    06-24-2013
    Location
    Reading CA
    MS-Off Ver
    Excel 2010
    Posts
    10

    I need a macro that will automatically hide a row when the sum of a row = 0

    the attached spreadsheet the print range has been set and I would like to create a macro that automatically hides rows that equal zero within that print range (always A1:N138). the rows that need can be hidden are row 6 through 138. the rows shaded in Blue will never be hidden. But if the sum Column A:N equals 0, that row should hide. If we change the number in A4 (a variable) the rows with the new values should be displayed. the macro should also include a print of the page once the macro is completed.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I need a macro that will automatically hide a row when the sum of a row = 0

    Hi,

    Seems to me that the simplest way is just to filter all non zero value with the single line macro

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: I need a macro that will automatically hide a row when the sum of a row = 0

    Hello rjackson104,

    I have added the macro below to a button at the top of the worksheet to run macro shown below. The button will not print. The attached workbook contains these changes.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    06-24-2013
    Location
    Reading CA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: I need a macro that will automatically hide a row when the sum of a row = 0

    thanks Richard,

    This does not seem to work. When running the macro using the criteria, it indicates that it cannot run it in break mode. Which it shouldnt. It also says the command could not be completed by using the range specified. Selct a single cell within the range and try the command again. Only one cell was selected

  5. #5
    Registered User
    Join Date
    06-24-2013
    Location
    Reading CA
    MS-Off Ver
    Excel 2010
    Posts
    10

    Re: I need a macro that will automatically hide a row when the sum of a row = 0

    This is awesome, thank you very much

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: I need a macro that will automatically hide a row when the sum of a row = 0

    Seems to work OK for me. Obviously VBA should not be in Break Mode though.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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