+ Reply to Thread
Results 1 to 54 of 54

Macro/VBA for auto hide unhide rows

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Macro/VBA for auto hide unhide rows

    This is the second thread I make over here, but it concerns the same question from my first thread (but a little more difficult, since I had to change my sheet)

    Attached, you can see my file where the code has to it's work

    I'll try to explain it simple, but if I wasn't clear on something, please ask me.

    ROW 12 = always visible
    ROW 13= hiden if C12 & D12 & E12 & F12 & G12 are empty. From the moment the user makes an input in one of those 5 cells, ROW 13 should unhide
    ROW 14= hiden if C13 & D13 & E13 & F13 & G13 are empty. From the moment the user makes an input in one of those 5 cells, ROW 14 should unhide
    ...
    ROW 21 = hiden if C20 & D20 & E20 & F20 & G20 are empty. From the moment the user makes an input in one of those 5 cells, ROW 21 should unhide

    Same store on ROW 41 till 50; 65 - 74; 80 - 89; 92 - 94.
    Always one row that is always visible by default (the first one), and the ones behind become visible from the moment user makes an input in the row before.

    It's important that the code has no restrictions on the amount of rows, because rows will be inserted or deleted in time (concerning rows 4 - 11; 22 - 40; ...)
    Next thing very important to me, is that the excisting macro's (color cells with comment & make user input auto uppercase) keep working.
    And last but not least: if C12 & C13 & C14 has an value, and the user deletes C13, C14 should keep being visible (in my thread before it was hiding rows with values in).

    Hope I made it clear enough
    Thanks for any help in advance !
    Attached Files Attached Files

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    Try this:Flex 2015.xlsm
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Hi xladept,

    The code does auto hide and unhide, but not the rows that I need to be hiden or unhiden.
    Entering a value in C12 (eg) doesn't unhide row 13.
    Row 22 is a fixed value and should always be visible. But it hides from the moment Row 21 is blank.
    And another problem: if C12, C13 and C14 are not blank, and I delete the value in C13, row 14 hides while it is not empty.

    Grtz
    Kristof

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof,

    I'll look at it again tomorrow.

  5. #5
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Ok thanks man !

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    Try this:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-17-2014
    Location
    new york
    MS-Off Ver
    2013
    Posts
    1

    Re: Macro/VBA for auto hide unhide rows

    I am trying to create a macro in cell B35. Cell C35 captures a value from other worksheets. There is a circular reference. I want B35 to have a macro that will continue with the circular reference until the value in B35 is equal to or close to the value in C35. the circular reference should stop when the values are close.
    Right now I have to copy paste the value from C35 to B35 several times until the values are equal.
    Can someone help? I dont know how to write macros.

  8. #8
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by xladept View Post
    Hi Louvaek,

    Try this:

    Please Login or Register  to view this content.
    Hi xladept,

    That code works fine for the hiding part.
    Only the unhide doesn't work. If I enter a value in C12, row 13 should unhide, so the user always has one empty line to make a new entry.

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    I've modified the Code from your previous Thread...see if it does as required
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  10. #10
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by jaslake View Post
    Hi Kristof

    I've modified the Code from your previous Thread...see if it does as required
    Please Login or Register  to view this content.
    Hello Jaslake,

    Same issue with your code, the hide row thing works fine, but it doesn't unhide when a value is entered.
    E.g. : c12 ==> user inputs a name, C13 should unhide so user has a new blank line for a new name.

    Grt
    Kristof

  11. #11
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    It appears to work for me...see attached
    Attached Files Attached Files

  12. #12
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    @sabs2014

    Welcome to the Forum!!!

    Please don't hijack another Members' Thread, start your own...see Forum Rule #2

    2. Don't post a question in the thread of another member -- start your own. If you feel it's particularly relevant, provide a link to the other thread. You may include up to 3 links to other URLs in a single post, no more, so only link to the relevant pages.

  13. #13
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    That's strange. Your file that you attached does not work to for me
    I've put the letter F in C12, C13 doesn't unhide

    Don't understand it ...
    Attached Files Attached Files

  14. #14
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    I repeated this on your upload and it worked as expected...what Version of Excel are you running...you have, I assume, Enabled Macros.

    I've put the letter F in C12, C13 doesn't unhide

  15. #15
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by jaslake View Post
    Hi Kristof

    I repeated this on your upload and it worked as expected...what Version of Excel are you running...you have, I assume, Enabled Macros.
    Excel 2007 ... not enabling macro's would be really stupid and the hiding part works fine
    What version are you working with?

  16. #16
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    I found a very strange thing Jaslake

    If C12 is blank, and I press DELETE, C13 unhides. If I'm on C13 and push DEL, C14 unhids, and so on and so on.

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    This is strange, if I trigger the code by code - it works? i.e.
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    If found the problem, but now I have another one :p

    In my file, I had a module too, wit ha vba to trigger cells with comments (so I could add conditional format).

    From the moment I cleared that module, your code did work.
    But now my 'comments' code doesn't fit in

  19. #19
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Function HasCmt(Rng As Range)
    Application.Volatile
    HasCmt = Not Rng.Comment Is Nothing
    End Function

    That's the comment triggering. Can I fit in this code in my worksheet code?

  20. #20
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    That's why this was posed as a Statement, not a Question
    you have, I assume, Enabled Macros
    I'm also running 2007.

    How, when, where in your File are these Comments? Please explain the process.

  21. #21
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Well, I need the cells with a comment made by user, to be different from the rest.
    So I was looking to do something with conditional formatting. But you can't use cond. format if the cell has a comment, so I used that code (I found it on this forum) to help out the standard Cond. F in Excel.

    Everything in the sheets in my workbook should be highlighted after inserting a comment. And that worked perfectly, but now I had to delete it to make your code work

  22. #22
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    Are there any Comments in your most recent Upload? Point us to an example we can work with.

  23. #23
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by jaslake View Post
    Hi Kristof

    Are there any Comments in your most recent Upload? Point us to an example we can work with.
    In my upload now, I have 3 cells in blue with white font. That's the Cond Format rule '=hascmt()'.

    Right click, insert comment, and that code did the rest.
    Attached Files Attached Files

  24. #24
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    I've modified the Code slightly to accommodate this
    If C12 is blank, and I press DELETE, C13 unhides. If I'm on C13 and push DEL, C14 unhids, and so on and so on.
    I'm unable to break the Code. Adding Comments appears to work and appears to not impact the Hide/Unhide Code and the Hide/Unhide Code appears to not impact the Comments CF.

    Tell me what you're doing, Step by Step when it breaks for you; please describe WHAT'S broken.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  25. #25
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    There is not really a step by step problem.
    The book you sent me in you're last reply, works fine except the auto unhide.
    If I fill in C12, row 13 doesn't unhide.

    BUT:
    From the moment I remove the 'Function HasCmt' in Module 1, the auto unhide starts working.
    But then the auto format cells for cells with comments doesn't work anymore, because I had to remove the code to make your hide/unhide code work.
    I see you do know what the auto format cells means, because you inserted comment in the sheet to test it.

  26. #26
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    Does that mean that my code also works now?

  27. #27
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by xladept View Post
    Hi Louvaek,

    Does that mean that my code also works now?
    Xladept,

    No I wish it would ... Tried it out again and removed the 'hascmt' code too, but the unhide still doesn't work with your code.

  28. #28
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Could somebody on this forum test out the latest attachment from Jaslake too, and reply if it works?
    It doesn't when I try, except when I remove the Module 1 ...

    Please do tell me if ROW13 unhides when I fill in C12
    Becoming really stressed about this

  29. #29
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof


    I don't know...I can't duplicate the issue. Hopefully another will test to see what's happening for them.

    For me, C12 is blank and Row 13 is hidden. I enter F into C12 and Row 13 becomes visible. I enter G into C13 and Row 14 becomes visible.

    Insert a Comment on any cell in Columns C through G and CF works.

    I've ask the Cavalry to look at and test it.
    Last edited by jaslake; 11-17-2014 at 06:33 PM.

  30. #30
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    It works like this:Flex 2015.xlsm

  31. #31
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by jaslake View Post
    Hi Kristof


    I don't know...I can't duplicate the issue. Hopefully another will test to see what's happening for them.

    For me, C12 is blank and Row 13 is hidden. I enter F into C12 and Row 13 becomes visible. I enter G into C13 and Row 14 becomes visible.

    Insert a Comment on any cell in Columns C through G and CF works.

    I've ask the Cavalry to look at and test it.
    Comments indeed do work, for me too.
    Just the unhide doesn't. I attached a little screenshot just to show I'm not messing with you
    Attached Images Attached Images

  32. #32
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by xladept View Post
    Hi Louvaek,

    It works like this:Attachment 359478
    Yes the unhide en hide things works in jour book, but the comments don't.
    I see you took them out by making them text instead of code.
    From the moment I take away your ' s, the unhiding stops

    And should you know what's the reason the simple formula's in I4:M11 stopped working?
    It's a simple VLookup that worked before editing with hide-unhide-code.

  33. #33
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    I'm unable to view png images for some reason. I don't think you're messing with me.

  34. #34
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Marco Unhide.jpg
    Quote Originally Posted by jaslake View Post
    Hi Kristof

    I'm unable to view png images for some reason. I don't think you're messing with me.
    It's just, the English makes it harder to explain and I don't always feel we understand each other
    Last edited by louvaek; 11-17-2014 at 07:05 PM.

  35. #35
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    Unfortunately, I can't view this image either. I've had this issue for several weeks and it's been reported.

    Language can sometimes cause issues regarding understanding. I think your English is fine as I know what you wish the end result to be.

    One thing for which you may have not gotten my meaning...when I said Step by Step. I was looking for the actual Keystrokes you make. I wanted to duplicate your Keystrokes to see if I could duplicate the problem you're having.

    We'll get it sorted...hang in there.

  36. #36
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by jaslake View Post
    Hi Kristof

    Unfortunately, I can't view this image either. I've had this issue for several weeks and it's been reported.

    Language can sometimes cause issues regarding understanding. I think your English is fine as I know what you wish the end result to be.

    One thing for which you may have not gotten my meaning...when I said Step by Step. I was looking for the actual Keystrokes you make. I wanted to duplicate your Keystrokes to see if I could duplicate the problem you're having.

    We'll get it sorted...hang in there.
    Well by actual keystrokes you mean type out every move or push on the keyboard?
    I open the .xlsm that is working just fine for jou. I go to C12 and type a name in, random.
    Row 13 doesn't unhide ...

    There's no much more to say 'bout that. We have the same worbook, sheet, the same Excel version, and try to do the same thing.
    Maybe it's an excel option?

    I really have no clue. I hope that this person you call Cavalry, can help me out
    I'll see it tomorow, it's 00u48 AM over here

  37. #37
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Macro/VBA for auto hide unhide rows

    Hi Kristof

    Have a good nights rest...

  38. #38
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Good Night Kristof.

  39. #39
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Macro/VBA for auto hide unhide rows

    Copied from Call in the Cavalry.

    @jaslake: something very strange is going on with this workbook/worksheet/code. I have put a Stop in at the top of the Worksheet_Change event handler. If I make a change in column A, it Stops, as expected. If I make a change in column C, it does not Stop. It does, however, convert a lower case x to an upper case X ... but it doesn't unhide the rows.

    I'm guessing it has something to do with the UDF HasCmt which is applied to all the range of interest. CF formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    applied to
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    Please Login or Register  to view this content.

    I note that when the UDF is commented out, my Stop is complied with. With the Stop working, you can step through the code. What is happening is that the first bit of code converts the content of the cell to Upper Case but the second Undo causes an error and goes directly to the Reset: label without executing the Unhide Row code. So, if you switch off the error trap you get Run-time error '1004': Method 'Undo' of object '_Application' failed.

    That's the problem. What to do about it ... over to you. Maybe you can't have an undo stack in VBA because VBA routines clear the undo stack.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  40. #40
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    @Trevor - Thanks but I think we need to be able to alter the volatile element of the UDF

  41. #41
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    For me, the unhiding/hiding is way more important than the comment highlights.
    It would be nice to have them both, but If I had to choose, I would go for unhiding every time.

    But stil, my hopes are on for someone to find a solution

  42. #42
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    I have to start working on the rest of the workbook now, so I'll leave out the CF thing ...
    I want to say, I really like the help I've got here, especially from xladept and jaslake!

    The reason why this thread has been opened, was the hide-unhide problem, and that's solved so I am a happy man
    Admin's can close it now.

    Thx again, you 2 rock

  43. #43
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro/VBA for auto hide unhide rows

    Why do you put the NewValue into the cell and then try and Undo again here:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  44. #44
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Macro/VBA for auto hide unhide rows

    Strikes me as there are three or four things that (may) need to happen.

    1. convert to upper case
    2. check if the old value was blank
    3. hide or unhide rows
    4. check for comments in cells


    1. If the cell needs to be upper case, you don't really need to check it, just make it upper case.
    2. You can use a Selection_Change event handler to record the value in the cell (in a global variable) when the cell is selected.
    3. You can check the current (Target) value and take appropriate action; unhide or hide rows

    The code below covers these points.

    Please Login or Register  to view this content.

    Not sure what to do with the HasCmt UDF. It appears to work although it clearly interferes with the execution of the code in some way. But that's not the reason for the fail; it is the Undo that causes the failure. I'll have a look at this and see if it is an issue in isolation.

    Regards, TMS

  45. #45
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Macro/VBA for auto hide unhide rows

    OK, I have tested the HasCmt UDF and it is definitely a problem

    Regardless of whether or not the Application.Volatile is present in the function, the function prevents the insertion of rows IF the Target cell is in the area covered by the Conditional Formatting (which uses the function). If the Target cell is in, say, column A or B, the Worksheet Change event works effectively.

    See the simple workbook which demonstrates the problem.

    Regards, TMS
    Attached Files Attached Files

  46. #46
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by TMS View Post
    OK, I have tested the HasCmt UDF and it is definitely a problem

    Regardless of whether or not the Application.Volatile is present in the function, the function prevents the insertion of rows IF the Target cell is in the area covered by the Conditional Formatting (which uses the function). If the Target cell is in, say, column A or B, the Worksheet Change event works effectively.

    See the simple workbook which demonstrates the problem.

    Regards, TMS
    Hey TMS,

    Thx for investigating this, but I'm a big VBA noob and I have still lot to learn about this.
    I do not understand half the things you are saying That code you gave, is that a code that I can paste in my sheet, or is it written for a example sheet like in your last post?

    grt
    Kristof

  47. #47
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Macro/VBA for auto hide unhide rows

    FWIW, UDFs in Conditional Formatting can be very problematic.

    For example, if you don't have error handling in the UDF, and try and access certain properties of a range, such as HasArray or HasFormula, it can cause all running code (such as event code) to silently terminate.

    Unfortunately, using Get.Cell to determine if the cell has a comment seems to cause Excel to crash frequently, so I wouldn't recommend that as a workaround!

  48. #48
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Macro/VBA for auto hide unhide rows

    @louvaek: the code provide is a simplistic example. It applies to any and all cells on the worksheet. It could be adapted to check for specific ranges.

    As far as I can see, the current Worksheet_Change event is only constrained to specific columns but NOT specific rows.

    Regards, TMS

  49. #49
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    TMS,

    What attatchment or sheet did you use? Because when I copy your code into my sheet, it doesn't work (except for the UCASE).
    Can you take the attachement where you tried it on, and attach it to your response?
    If you didn't try it on an attachment, could you just copy it in one where it should work?


    grt
    Kristof

  50. #50
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: Macro/VBA for auto hide unhide rows

    The code below will be limited to the ranges of interest. It will highlight cells with comments and it does not use the HasCmt UDF


    Please Login or Register  to view this content.

    It has not been destruction tested but, unfortunately, I don't have time to do that right now.

    See the example attached.


    Regards, TMS
    Attached Files Attached Files

  51. #51
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Hi Louvaek,

    Thanks for the rep! - If you run this again after the dust settles, it will unhide your rows

    Please Login or Register  to view this content.

  52. #52
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Quote Originally Posted by xladept View Post
    Hi Louvaek,

    Thanks for the rep! - If you run this again after the dust settles, it will unhide your rows

    Please Login or Register  to view this content.
    It indeed does the job Xladept ! Thanks
    I'm afraid the dust will never go away, I do not know enough VBA to understand some poeple over here and I don't have the knowledge to put their codes into my worksheet

  53. #53
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Macro/VBA for auto hide unhide rows

    Not many of us understand the volatile function intricacies - I certainly don't

  54. #54
    Registered User
    Join Date
    10-17-2013
    Location
    Ardooie
    MS-Off Ver
    Excel 2007
    Posts
    67

    Re: Macro/VBA for auto hide unhide rows

    Xladept,


    I used your code, because it was the only one working after I edited the file and changed the last details (mostly formatting).
    Now my file is ready. I'll attach it, in case you are interested in helping me once again.

    So your code works fine, but the only thing is: my sheet is so slow each time a make a change in the worksheet.
    My laptop at home is one of the newest, and here it works between fast and slow. But at work, we have old computers and each time I input a value, it takes half a minute before I can work again.

    Is that something that can be changed? Or what can I do to make it work faster?
    The sheet attached has the name '01'. That's a week number, so 51 more sheets like these will be added to the excel file
    I guess that won't help the speed

    Hope you, or anybody else that's willing to be so friendly, can help me out once again, it would be great !!

    Thx!
    Kristof
    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. [SOLVED] Auto hide/unhide rows that have empty cells ( Preferably VBA Code)
    By carlandtina02 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-09-2016, 07:06 PM
  2. [SOLVED] How to auto hide/unhide rows based on value of sum
    By wesleeptheylive in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-27-2013, 04:34 PM
  3. [SOLVED] Auto Hide and Unhide Rows Based
    By Kosmik in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2013, 10:09 AM
  4. Auto Hide & Unhide Rows Upon Sheet Selection
    By Sleeper in forum Excel General
    Replies: 4
    Last Post: 01-24-2013, 02:00 PM
  5. Auto Hide or Unhide rows.
    By Michael S in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-19-2009, 06:04 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