+ Reply to Thread
Results 1 to 39 of 39

Hide Row when Cell in column A =0

  1. #1
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Hide Row when Cell in column A =0

    Hi there,

    I have tried NUMEROUS examples from this forum and other ones this morning to help me with my issue, but unbelievably not one of them is working for me. (Crazy world).

    It's really simple:..if Cell A5 goes to zero because of a result from a formula, Row 5 must hide. The range runs A5 to A50. If A21 equals 0, then row 21 must hide...

    Please Help...please...

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Hide Row when Cell in column A =0

    Here is an example of some code you will need to adapt to your situation.

    http://stackoverflow.com/questions/1...d-by-a-formula
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    thanx..I'll see what I can do..

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    Hi juriemagic,

    Though this is more cluncky in that it will run on every change in the active sheet, as there's only 46 rows this event macro should suffice:

    Please Login or Register  to view this content.
    Note this macro needs to inserted on the sheet in question as per the last screen shot of the link Alan provided.

    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  5. #5
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Trebor76,

    well, yep, the code is running and working..and yes, I DO REALLY appreciate your help, however there are other problems.
    the code runs for every little thing I do on the spreadsheet..Now..it wouldn't have been an issue, if only the time taken to calculate would be immediate. It really takes almost 3 seconds to calculate during which time the everything is basically on halt. Do you maybe know of a way around this?..

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    You can try this where there's a combination (Change and Calculate) of worksheet events:

    Please Login or Register  to view this content.
    No other suggestions after this I'm afraid. Did the link that Alan provide help?

    Robert

  7. #7
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Thanx, I am going to try this code just now..

    I did look at Alan's suggestion, but I'm confused..I see there are more than one place where you have to insert different parts of the code?..Or am I just stupid..it's okay, I can take it..

  8. #8
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    well,

    If I change the cells manually, the row hides, but the cell values are actually dependant on other cell values, so when I change the other cell values to 0, the cells in my range update, but the rows do not hide. I know you said you're out of options..but ..just maybe you know a way out of this one?

  9. #9
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    but the cell values are actually dependant on other cell values
    That's why I incorporated two worksheet functions - refer my note in the WorkSheet_Calculate event macro.

    The code worked for me Do you have the calculation method set to manual?

  10. #10
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Trebor76,

    Thanx a lot, really, I mean that..uhm..the code runs, the rows hide and un-hide...I will use it like that. It just irritates me a bit that Excel takes so long to go through the calculation process. But thanx again for your time..

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    It just irritates me a bit that Excel takes so long to go through the calculation process.
    I just think that's the trade off I'm afraid. At least there's only 46 rows as it wouldn't take long for it to really get bogged down.

    If you could mark the thread as solved it would be appreciated.

    Cheers,

    Robert

  12. #12
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    Change the above Worksheet_Calculate event macro to this as it may help slightly:

    Please Login or Register  to view this content.
    Regards,

    Robert

  13. #13
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Robert,

    You've been helpful and very kind, thank you..It does seem to work a teeny bit faster, thanx.

    Just a question..is it right to have pasted OPTION EXPLICIT with the rest of the code all together?..

  14. #14
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Hide Row when Cell in column A =0

    You've been helpful and very kind, thank you..It does seem to work a teeny bit faster, thanx.
    You're welcome and thanks for marking the thread as solved

    Just a question..is it right to have pasted OPTION EXPLICIT with the rest of the code all together?
    Option Explicit is only shown once at the very top of each module. It forces you to declare all variables before they are used as opposed to Excel assigning them, which in that case will always be as a variant - the most expensive type of variable in programming terms. This can adversely impact code.

    Glad we got there in the end (sort of anyway).

    Robert

  15. #15
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Rows Hide and Unhide

    hi all,

    I have posted this before, but have to date not received a proper solution. I have also included a basic spreadsheet to work on. Please, I desperately need some advice here. Sheet 1 has formulae that looks at sheet 2. Sheet 1 also contains a code. If I manually change any of the values on sheet 2, sheet 1 updates. The code is supposed to hide and un-hide the rows with zero values. It is however not functioning properly. Please help with this. Thank you all very much..
    Attached Files Attached Files

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

    Re: Rows Hide and Unhide

    In fact you don't need the formula reference to sheet2 and you can control it in sheet2 sheet change event itself.

    Refer the below code...

    Please Login or Register  to view this content.
    Refer the attached file
    Attached Files Attached Files


    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

  17. #17
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Rows Hide and Unhide

    Hi SixthSense,

    Thank you for your prompt reply. I have pasted your code into my actual spreadsheet and found it won't work. Okay, I do realize the error is on my side for I have not given the full story. (I apologise). I have altered the worksheet. Sheet 2 contains a dropdown, and depending on selection, sheet 1 updates. however the rows in the yellow column do not hide/un-hide. Maybe just a small change somewhere?. I appreciate your time on this..
    Attached Files Attached Files

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

    Re: Rows Hide and Unhide

    Replace the previous code with the below one...

    Please Login or Register  to view this content.
    In Sheet1 A10 Cell the group2 mentioned without space. So keep the constant Group heading in both of the sheets.

  19. #19
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Rows Hide and Unhide

    Hi,

    I have done as you said, but I don't know, its still not working. I have attached the sheet with changes. To be honest with you, I have reached the stage where I'm just so fed-up with this....it's been daayyyys now, and I just don't seem to find a solution. I appreciate your help..
    Attached Files Attached Files

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

    Re: Rows Hide and Unhide

    Sorry you are not at all understanding my point. I can't go further....

  21. #21
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Rows Hide and Unhide

    unfortunately, as you already said in your first post:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules.

    As you have replies in both of your threads i'll merge them just for this time respecting the effords and the time of the members that replied to you.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  22. #22
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    If you are changing a dropdown on Sheet2, then switching to Sheet1 to see the results, then you could use the Worksheet_Activate event of Sheet1:

    In the Sheet1 module:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  23. #23
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Olly,

    well, no I actually have a graph on sheet 2, which gets it's data form sheet 1. So I am viewing the graph really. The graph need to display only values and legends which are more than zero...thanx for your input..

  24. #24
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    Quote Originally Posted by juriemagic View Post
    Sheet 2 contains a dropdown, and depending on selection, sheet 1 updates.
    Requirement gathering by installments is a massive pain. You seem to keep changing the requirements with each potential solution. YOU know the constraints of your workbook, and what you are trying to achieve. WE only have the stuff you post to work with.

    Attach a workbook which accurately reflects your actual requirement, instead of wasting a lot of time revealing only snippets or inaccurate examples of how your workbook is put together.

  25. #25
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    I understand..To me it should be necessary to post only the problem area, and not the whole thing..I guess my approach is wrong..I humbly apologise.

    I have updated the spreadsheet to what it must be. When a cell in column B sheet 1 changes to zero, that row must hide. I want to see the change happening by staying on sheet 2, and viewing the graph. Then also, should the rows on sheet 1 un-hide when criteria changes from 0 to any value. This is achieved by using the drop down on sheet 2.

    once again, forgive me please..it certainly is not my intention to beat around the bush...
    Attached Files Attached Files

  26. #26
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    What we're clear about is a method which works to hide the necessary rows. What we're trying to understand is how to trigger that change.

    In your latest example, the trigger is changing the dropdown value in Sheet2!A1. So let's capture that worksheet_change event for that range, and hide / unhide the rows on Sheet1 when that happens - so put this in the Sheet2 module (replacing the code that is already there):

    Please Login or Register  to view this content.

  27. #27
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Hide Row when Cell in column A =0

    Your post does not comply with Rule 8 of our Forum RULES. Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    CrossPosted: http://www.mrexcel.com/forum/excel-q...ml#post3980268

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

  28. #28
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Well I certainly do not intend to waste other people's time. The reason for the cross posting was because I am looking for a smoother answer, as I feel I have exhausted all chances of getting a better answer on Excel Forum. (No rudeness intended). The answers I got, work, but they are all slow and sluggish when fired. I marked them as solved, because they are working nonetheless.

    I did not realise that all the forums had anything to do with each other, I thought they were all "separate entities"..

    I also cannot think that any-one would post elsewhere if they had gotten a propper working suggestion in the first place.

    Anyhow, having said all that, I did not realise I was breaking any rules, please accept my apology...again..

  29. #29
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    No feedback to my post #26, then?

  30. #30
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Olly!!!!..gosh,

    sorry man..shucks, I seem to keep being in some kind of deep water!.

    Actually, I am using your code in my sheet. Your code so far is the best working of all the other suggestions I had, (I'm not putting anyone down)..
    uhm..just a very small issue with it, which is that it doesn't execute smoothly. What I mean is that..if I look at the graph and at lets say 20 legends, and I select fewer criteria (legends), the graph will now display still all the legends, including the ones which are zero. So the dashes representing the legends are still there. Now as your code kicks in because of the value changes that happened in column A of sheet 1, and the rows start to hide, I can see on sheet 2, still looking at the graph, the dashes disappearing one by one, with about half second between events.so..it's not an immediate smooth transition...however, the code works and that already is a great starting point..thanx to you..

  31. #31
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    So to smooth the visual effect, add a couple of lines to the code to disable screenupdating while it runs:
    Please Login or Register  to view this content.

  32. #32
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Hide Row when Cell in column A =0

    juriemagic: Just to put the record straight, the forums are not related. It is just that many people post to multiple forums and this type of situation does not go unnoticed. We have no issue with crossposting, but if you do, then please let people in both forums know. It is just a matter of courtesy and as you have just found out feedback is very important. Good luck with your excel adventures and we do look forward to seeing you here at Excel Forum.

  33. #33
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    No Olly,

    it's not between the 2 sheets..in other words its not flickering between the 2 sheets I'm talking about, the page stays on sheet 2, but the disappearing of the legends happens in instalments...I don't know how else I can explain it...

  34. #34
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    Did you TRY the amendment in post #31?

  35. #35
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Proverbs 3:5..Do not rely on your own understanding..

    I did it again. Your code is PERFECT, everything is exactly like I wanted it...Thank you Olly!!

  36. #36
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Hide Row when Cell in column A =0

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

  37. #37
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Hi Alansidman,

    I understand. I'm glad we can put this now behind us and move forward. Have a nice day..

  38. #38
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Hide Row when Cell in column A =0

    Quote Originally Posted by juriemagic View Post
    Proverbs 3:5..Do not rely on your own understanding..

    I did it again. Your code is PERFECT, everything is exactly like I wanted it...Thank you Olly!!

    Glad we got there in the end. Happy to help.

    There's a lot of help available on this forum, but you have to take the time to work out how best to work with people. A few pointers we can learn from this thread:

    We only know what you explicitly post - detail is everything. Don't assume other people will "get" something: explain it in detail.
    When you post an attachment to demonstrate your problem, make sure it matches both your description, and your eventual application.
    When someone suggests something, TRY it; don't assume you know better.
    Don't disappear if you don't get an answer you like in the first 5 minutes. Most of us are prepared to keep working with you to reach an eventual solution. We need you to work with us.


  39. #39
    Forum Contributor
    Join Date
    04-16-2014
    Location
    Witbank, SA
    MS-Off Ver
    Excel 2013
    Posts
    268

    Re: Hide Row when Cell in column A =0

    Agreed...

+ 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. [SOLVED] Hide Column if Cell in that Column Equals Certain Value
    By martinpgibson in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2013, 12:34 AM
  2. [SOLVED] Hide Column if Cell has a value of 0
    By Sky188 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-04-2012, 02:08 PM
  3. hide cell contents without column or row hide
    By ravergirl7216 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-30-2010, 11:20 AM
  4. Hide Column Off of Cell Value
    By DGA2008 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-14-2008, 11:41 AM
  5. [SOLVED] Hide column or row based on a cell in the column or row?
    By SacGuy in forum Excel General
    Replies: 0
    Last Post: 01-24-2006, 02:55 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