+ Reply to Thread
Results 1 to 14 of 14

Macro to hide all rows with a zero

  1. #1
    Registered User
    Join Date
    10-14-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Macro to hide all rows with a zero

    Hi all

    I have been trying to find a macro which will hide any rows where the entire range in columns C:M has a value of 0. I have found a macro which comes close but it seems to hide a bit too much.

    If you see the attached sheet you will see I have highlighted some rows in Red these are rows I don't want this macro to hide and rows in Yellow which is does hide and I want it to hide.

    If anyone can help me perfect this macro so it doesn't hide the red rows I would be grateful.DSO Report Latest (version 2) static.xls

    This is the macro.

    Please Login or Register  to view this content.
    Last edited by CFlack8472; 07-26-2013 at 08:35 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Macro to hide all rows with a zero

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    10-14-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro to hide all rows with a zero

    Does anyone have any ideas? I was hoping this was a fairly simple request.

  4. #4
    Registered User
    Join Date
    07-24-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    11

    Re: Macro to hide all rows with a zero

    Here is what I am using to do this.

    Please Login or Register  to view this content.
    I have this residing in my Sheet1 and then its automatic. Hope that helps, the only difference between mine and what you want to do is I was using a TRUE and FALSE formula to dictate what was being hidden.

  5. #5
    Registered User
    Join Date
    10-14-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro to hide all rows with a zero

    Hi Dberg

    Thanks for that but unfortunately it didn't hide the rows I marked in red in my initial version so my original macro is still better than your one.

    Does anyone else know how to write this macro so it doesn't hide the red rows?

  6. #6
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Macro to hide all rows with a zero

    Hi..

    Re-Reading..
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  7. #7
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to hide all rows with a zero

    Please Login or Register  to view this content.
    added if loop that overrides the value check
    Last edited by humdingaling; 07-29-2013 at 04:07 AM. Reason: ps i didnt check if your code does what its meant to i only added the color check
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to hide all rows with a zero

    Your colouring is quite confusing.
    Row 43 is yellow- it has two blank columns. Row 56 is red and has few blank rows.
    Is it for the row to be hide every single cell in that columns(C-M) have to be empty?

  9. #9
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: Macro to hide all rows with a zero

    with regards to AB33..

    try this..

    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    10-14-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro to hide all rows with a zero

    Quote Originally Posted by AB33 View Post
    Your colouring is quite confusing.
    Row 43 is yellow- it has two blank columns. Row 56 is red and has few blank rows.
    Is it for the row to be hide every single cell in that columns(C-M) have to be empty?
    Hi AB33 & Debaj. Thank you for your responses. AB33 you're correct I want this to only hide a row where the entire range C to M adds up to zero.

    What I'm doing is I have a workbook with 13 reports for various departments I need to run this on a monthly basis. Some departments have zero spend in some areas so I don't need to know about rows C - M if they add up to zero. They will just take up space on the paper and cause clutter.

    The macro I posted in my first post gets 95% of the way there except it is hiding some rows which are not zeroed which I do want to see (the red ones)

    Debaraj I think your first macro again does the same thing it was hiding the red rows - do you know how to make it so it will only hide the yellow rows in my example? I want to see the red rows.

  11. #11
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to hide all rows with a zero

    Try the attached.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Macro to hide all rows with a zero

    does post #7 not exclude the red rows from being hidden?

  13. #13
    Registered User
    Join Date
    10-14-2009
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: Macro to hide all rows with a zero

    Hi AB33 that works perfectly!

    I tried to edit the code so that it will do multiple worksheets. Could you post a version that will hide multiple worksheets? Otherwise this one will do.

    Quote Originally Posted by humdingaling View Post
    does post #7 not exclude the red rows from being hidden?
    Yes it did but AB33's most recent update hides only the ones I want it to hide.

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Macro to hide all rows with a zero

    Update code attached.
    Attached Files Attached Files

+ 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. Replies: 0
    Last Post: 05-10-2013, 12:04 PM
  2. [SOLVED] Hide rows macro
    By nickmax1 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-31-2012, 10:25 AM
  3. Using check boxes to hide and un-hide rows with drop down lists within rows
    By Sparky_Chris in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2012, 07:22 AM
  4. Macro to Hide and Unhide Rows but still be able to insert rows
    By majasmi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2011, 09:25 PM
  5. macro to hide rows
    By EdMac in forum Excel General
    Replies: 2
    Last Post: 02-02-2007, 08:12 AM

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