+ Reply to Thread
Results 1 to 13 of 13

Macro to hide rows when total column is zero

  1. #1
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Macro to hide rows when total column is zero

    Hi,

    I have been trying to work out how to hide rows when a total column is zero (without success!) . I could use the auto filter but i want it to do it automatically so that if a total changes from zero to a value in a hidden row then it becomes unhidden straight away without having to redo the filter each time, or press any buttons.

    I have a table; A9:T110, with column T being the total column. Data is entered in the same sheet but below the table in a list and the table summarises the data using a SUMIF so that it shows the total of any value that has been used more than once. Because the table has so many rows i would like to be able to only show the rows where there is a value in the total column (T). If a row is hidden because it is zero data is entered that then feeds into that row it automatically becomes unhidden. I hope that this makes sense?!?

    Is this possible and can anyone help? I am assuming that some kind of Macro will be involved.

    Many thanks,

  2. #2
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Macro to hide rows when total column is zero

    Hi Brit,

    It helps to post a dummy workbook so that we can take a look at the problem more easily.

  3. #3
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to hide rows when total column is zero

    Hi,

    Here is a sample of the workbook. I hope this helps and thanks for looking.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    06-20-2012
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to hide rows when total column is zero

    try to use this code in Cost worksheet:
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Macro to hide rows when total column is zero

    Ah Yes.

    I was also trying to arrive at the solution, but ran into syntax errors.

    Thanks to Power777 as well.

  6. #6
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to hide rows when total column is zero

    Thank you, but i think i must be being an idiot as i can't get seem to get it to work.

    I have tried copying and pasting code in as a module in visual basic but nothing seems to happen. I am sure the answer is simple but macro are not my strong point at all. Could you please tell me what i should be doing?

  7. #7
    Registered User
    Join Date
    06-20-2012
    Location
    PA
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Macro to hide rows when total column is zero

    you have to put this code not in separate module, but in your sheet11111111111111(Costs) Declaration because this event fires only when you change Costs worksheet.
    Also make sure that macros enabled in excel.
    Hope it help

  8. #8
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to hide rows when total column is zero

    I've got it working, HORAH!!!!!!!!!! Thank you for your help.

    Your help is very much appreciated, an excellent answer.
    Last edited by Brit; 06-20-2012 at 05:04 PM.

  9. #9
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to hide rows when total column is zero

    Sorry, i have a problem again.

    I have input code and all works fine as long as i have a value in every month. If i input a value directly into only one or two months then it does not appear in the top. I have attached workbook, please see line 192 where i have values for cost 95 but it is not unhiding the row above.

    Thanks,
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Re: Macro to hide rows when total column is zero

    Quote Originally Posted by ThePower777 View Post
    you have to put this code not in separate module, but in your sheet11111111111111(Costs) Declaration because this event fires only when you change Costs worksheet.
    Also make sure that macros enabled in excel.
    Hope it help
    Thanks.

    Sorry, i have a problem again.

    I have input code and all works fine as long as i have a value in every month. If i input a value directly into only one or two months then it does not appear in the top. I have attached workbook, please see line 192 where i have values for cost 95 but it is not unhiding the row above.

    Thanks,

  11. #11
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Macro to hide rows when total column is zero

    Hi Brit,

    I have fixed the problem.

    I think the problem was that the loop was set to end at column 19 when it should have been 20.

    Now if you have values only in a few columns on for 192, it will appear at the top.

    Lifeseeker

    replace existing code with this one:
    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    06-19-2012
    Location
    Kent, England
    MS-Off Ver
    Excel 2010
    Posts
    19

    Red face Re: Macro to hide rows when total column is zero

    Quote Originally Posted by Lifeseeker View Post
    Hi Brit,

    I have fixed the problem.

    I think the problem was that the loop was set to end at column 19 when it should have been 20.

    Now if you have values only in a few columns on for 192, it will appear at the top.

    Lifeseeker

    replace existing code with this one:
    Please Login or Register  to view this content.
    Amazing. Thank you for all your help, very much appreciated.

  13. #13
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: Macro to hide rows when total column is zero

    thanks to Power777 as well.

    I also learned something new!

+ 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