+ Reply to Thread
Results 1 to 14 of 14

Macro: Hide Rows if Value in first column = 0

  1. #1
    Registered User
    Join Date
    06-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Red face Macro: Hide Rows if Value in first column = 0

    Hi all,

    I'm looking for macro to hide rows if the value in the A column is equal to zero. I have searched through many posts however each usually has a slightly different requirement/scenario which means the macros don't always work that well for my situation.

    If possible, the macro should:

    a) Run each time a particular cell is changed, either G9 or O9
    b) Check the first cell of each row in column A (if possible, this would only apply to first 200 rows)
    c) If the value is 0, hide entire row.
    d) If the value is 1, unhide entire row.

    Thanks for reading!
    Last edited by Jamison; 06-11-2012 at 08:56 PM.

  2. #2
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Macro:You try to run the following macro

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    06-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro:You try to run the following macro

    Quote Originally Posted by Sa DQ View Post
    Please Login or Register  to view this content.
    Hi Sa DQ,

    Thanks for your reply.

    Could you explain how to implement that macro and will it work on changing a particular cell?

  4. #4
    Forum Contributor
    Join Date
    03-21-2012
    Location
    Ho Chi Minh city
    MS-Off Ver
    Excel 2003
    Posts
    180

    Re: Macro: Hide Rows if Value in first column = 0

    I can not help you because English too bad;

    Mostly I use the FIND() method

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro: Hide Rows if Value in first column = 0

    Hello Jamison,

    Say you do have a Cell in Column A which = 0, and a Macro hides the Row, as per your requirement, you would have to manually unhide that row to be able to enter a value in that particular Cell. Best bet would be to have two Macros which are "Fired" with the use of two Buttons. One Button to Hide Rows if criteria is met, and another Button to UnHide all Hidden Rows.

    If you could upload a small sample WorkBook, I could see how best I may be able to help you.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  6. #6
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Macro: Hide Rows if Value in first column = 0

    Put this in a worksheet module (right click the sheet tab, click view code and paste the code in the window that appears)
    Please Login or Register  to view this content.
    Put this in a standard module (Alt+F11 key, click Insert then Module, Paste the code in the window that appears)
    Please Login or Register  to view this content.
    But as Winon says if A9 contains a "0" then cells "G9" and "O9" will be hidden. Are you sure that is what you want?
    Also you didn't state what you wanted if the cells don't contain a "0" or a "1". I have assumed that you want those rows visible.
    Last edited by WasWodge; 06-09-2012 at 09:33 AM. Reason: added ScreenUpdating lines
    If my solution worked (or not) please let me know. If your question is answered then please remember to mark it solved

    Computers are like air conditioners. They work fine until you start opening windows. ~Author Unknown

  7. #7
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Macro: Hide Rows if Value in first column = 0

    Thinking about it, it is better to replace
    Please Login or Register  to view this content.
    With
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    06-07-2012
    Location
    Australia
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Macro: Hide Rows if Value in first column = 0

    Hi all,

    Thanks for your help so far.

    WasWodge, that works great! Thank you!

    Updating thread to [Solved].

  9. #9
    Registered User
    Join Date
    06-14-2012
    Location
    Orlando
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro: Hide Rows if Value in first column = 0

    I see the above data and am tryig to do a similar set up.
    Inserting the macro into an excel contract that will display only rows that have merchandise with quantities greater than 0.
    The macro when run will hide all rows with a 0 in C colum ranging between C4 and C66. i would like to link the macro to a button as well so when the user refreshes or ipdates data they can run the macro again
    thanks in advance
    Attached Files Attached Files

  10. #10
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Macro: Hide Rows if Value in first column = 0

    You should have really started a new thread and if needed provided a link to the old thread but...
    Attached Files Attached Files

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro: Hide Rows if Value in first column = 0

    I agree with WasWodge, you should start your own Thread.


    Maybe the attached WorkBook is what you are after.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    06-14-2012
    Location
    Orlando
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro: Hide Rows if Value in first column = 0

    Thanks guys,
    Just didnt want to upset the forum by posting another thread so similar. New thread posted!
    Ben

  13. #13
    Valued Forum Contributor WasWodge's Avatar
    Join Date
    08-02-2010
    Location
    Hampshire,England
    MS-Off Ver
    Office 365 and Office 2010
    Posts
    883

    Re: Macro: Hide Rows if Value in first column = 0

    We did both post answers in this thread in the attached sheets. We were both just advising you how you should do it in future before one of the moderators gets you. See the forum rules for more info

  14. #14
    Registered User
    Join Date
    06-14-2012
    Location
    Orlando
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Macro: Hide Rows if Value in first column = 0

    Thanks! i see the replies now. i am sorry to say not quite sure how to integrate. will close this thread and reply in the correct one with the actual spreadsheet. thought i could be smart enough to import the macro from sample into actual
    Guys thank you!

+ 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