98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Sheet hide unhide Macro
Sheet hide unhide Macro
Resolved · Urgent Priority · Version 2010
Sanjay has attended:
Excel VBA Introduction course
Excel VBA Intermediate course
Sheet hide unhide Macro
Hi,
Could you please help me to create 2 macro for a work book which has mulitple sheet (Sheet1,sheet2......sheet10)
First macro to hide the few macro from the workbook.
Second macro to unhide the hidden macro.
please let me know if you need any other information.
Thanks
RE: Sheet hide unhide Macro
any update on my query ?
RE: Sheet hide unhide Macro
Hi Sanjay
Thanks for your question!
Unfortnately, due to the nature of the content of your question, the relevant trainer won't be available to answer until tomorrow. They will try to get back to you as soon as possible.
Sorry for the inconvenience.
Regards,
Sarah
Excel Trainer
RE: Sheet hide unhide Macro
Hi Sarah,
Do we have any update on my query?
Thanks
Sanjay
RE: Sheet hide unhide Macro
Hi Sanjay,
Thank you for the forum question and I am sorry that you have had to wait for an answer.
I am a little bit confused of what you want. Do you want to hide sheets or macros?
If it is sheets you want to hide/unhide
To hide:
ActiveWorkbook.Sheets("Name").Visible = xlSheetVeryHidden
To unhide
ActiveWorkbook.Sheets("Name").Visible =xlSheetVisible
To hide macros programmatically is a complicated task, and you should just use a password to hide the module.
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Sheet hide unhide Macro
Thanks Jane for your reply.
My issue is that I have a workbook which have 45 sheets and I have to use a macro so that i can hide approx 30 Sheets in one go.so the users cant access those sheets.similarly another macro will unhide those sheets for modification.
I hope my requirement is clear now for you.
Thanks
Sanjay
RE: Sheet hide unhide Macro
Hi Sanjay,
The code as written in my answer:
To hide:
ActiveWorkbook.Sheets("Name").Visible = xlSheetVeryHidden
To unhide
ActiveWorkbook.Sheets("Name").Visible =xlSheetVisible
You can use loops and a decision code: (you will have to add/amend the sheet numbers in the Case line)
Sub HideSheet()
Dim Sh As Worksheet
For Each Sh In Worksheets
Select Case Sh.Index
Case 2, 5, 6
Sh.Visible = xlSheetVeryHidden
End Select
Next
End Sub
Sub UnhideAllSheets()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
ws.Visible = xlSheetVisible
Next ws
End Sub
Kind regards
Jens Bonde
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
RE: Sheet hide unhide Macro
Thanks Jane.
Will check and let you know if i have any issue.
Thanks again.
Sanjay
RE: Sheet hide unhide Macro
Hi Sanjay,
You can also add the following at the top of your module to hide the macro from Excel buttons and front end access in addition to protecting your code.
Option Private Module
MSDN explanation is at:
https://msdn.microsoft.com/en-us/library/aa266185 (v=vs.60).aspx
Kind regards
Fiona
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Stop Formula Returning A "#DIV/0" ErrorIf a formula returns a #DIV/0 error message there is a way to avoid such results. |