+ Reply to Thread
Results 1 to 11 of 11

Hide/Unhide Rows VBA code Changes Help

  1. #1
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Hide/Unhide Rows VBA code Changes Help

    Hi there,
    I have found and adapted a piece of code which works extremely well however there are a couple of bits I need to change and wondered if anyone could help.

    I have a 'Department Codes' sheet which the user can select departments the want by putting a 'Y' in column E.

    In the main sheet (Reviews) where the VBA code is, I use the following formula
    =INDEX('Department Codes'!E:E,MATCH(Reviews!B86,'Department Codes'!B:B,1))
    This brings in all the 'Y' that match into column A.
    The VBA code I use keeps all the Y rows visible and hides all other rows.

    Please Login or Register  to view this content.
    I need to speed the process up, so is it possible to make the Code only update when I make a change to the 'Department Codes' sheet rather than updating after every change in the whole workbook?
    Also the VBA code now doesn’t allow me to Undo/Redo any changes I make, is there an additional piece of code to allow me to use the function again?
    And lastly, I want to protect the 'Review' sheet from changes being made however when it is protected the VBA code doesn’t hide/unhide the rows, is there code I can use to override this?

    Any help would be greatly appreciated.

    Thanks
    Justin.
    Last edited by Justinmih; 05-12-2011 at 04:26 PM.

  2. #2
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi,

    Try this

    Please Login or Register  to view this content.
    HTH
    Kris

  3. #3
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi Krishnakumar,
    Thanks for replying so quickly.

    The code has worked really well, I only had to change the 'Y' as it was hiding the wrong rows and leaving the blanks visible so i have changed the 'Y' to a '0' so it is now hiding the correct rows.

    I have added the code to another sheet within the workbook, it uses the same froumla to pull the
    data in but provides me with other information.
    The code doesnt seem to protect all of the sheet this time as it leaves Coloum A,C unprotected, is there a way to fix this? It does protect the 'Review' sheet 100% as originally hoped.

    It also seems to be updating every time a make a change, is there a way to upate only if i make a change to the 'Department codes' sheet only? as that is the only sheet the directly impacts on the rows to be hidden or displayed.

    Thanks again for all your help, its great.

    Cheers

    Justin.

  4. #4
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi,

    This goes in the Worksheet_Deactivate module of 'Department Codes' sheet

    Please Login or Register  to view this content.
    HTH

  5. #5
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi there,

    Thanks for all the time you have spent on this, it really is appreciated.
    I think we are almost there.
    The only thing is it doesn’t seem to want to hide is column C in any of the sheets I have the code in including the 'Reviews' sheet?
    Also the redo/undo buttons don’t work in any of the sheets and the only other thing I have noticed is that the cursor Box has disappeared and also the tab button seems to be disabled is there a way to fix it?

    Cheers again for your help

    Justin.

  6. #6
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi

    I'm not getting you

    What's the code you are using in Review sheets ?

    Do you want to hide Col C every time ? or is there any criteria for hiding the Col C as well ?

  7. #7
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi there,

    Sorry for the confussion I ment to say it does not protect column C (not hide as I mentioned in the last post) sorry.
    The first piece of code you gave me is used in the 'Reviews' sheet and the last piece of code you posted is now in the 'department codes' sheet.

    Thanks again

    Justin.

  8. #8
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi,

    You don't need to use 'Review' sheet code any more. Unprotect the sheet and > Select Col C > Format cells > Protection > check on Locked. Protect the worksheet again.

    HTH

  9. #9
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi there,
    I Have removed the old code and protected column C as you have described and it all works now, all the issues I was having with cursors, tabs etc are now fixed. Thank you so much!

    Could I just ask one last question..... I need to add another sheet in that will be set up in exactly the same way as the 'Review' sheet With the formulas etc as described in my first post, I tried to add and extra line to your code like below however it didn't work as it only updates the first sheet that you go into, is there a way that it would update both sheets or that I could add further sheets to it in the future.

    [code]
    set r = sheets("Training Summary").Range("a7:a454")
    [\code]

    Once again I really appreciate the time you have given up for me.

    Thank you so much

    Justin.

  10. #10
    Forum Contributor
    Join Date
    02-19-2005
    Location
    Gurgaon,India
    MS-Off Ver
    2007,2010,2013
    Posts
    180

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi,

    Remove all the codes from the 'Department codes' sheet and paste the following one.

    Please Login or Register  to view this content.
    HTH

  11. #11
    Registered User
    Join Date
    11-05-2007
    MS-Off Ver
    Mac 2011
    Posts
    98

    Re: Hide/Unhide Rows VBA code Changes Help

    Hi Kris,

    Thanks so much it works perfectly!

    Thanks so much for all the time you have spent helping me.

    Cheers Again

    Justin.

+ 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