ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro fundamentals (https://www.excelbanter.com/excel-programming/381742-re-macro-fundamentals.html)

Dave Peterson

Macro fundamentals
 
I started with Tom's suggested code:

Sub visible_sheets()
Dim sht As Worksheet
worksheets("policy information").visible = xlsheetvisible
For Each sht In Worksheets
If lcase(sht.Name) < "policy information" Then
Sht.Visible = False
End If
Next
End Sub

If you're unlucky, "policy information" could be hidden and you could end up
with an error--since at least one sheet needs to be visible.



Brad wrote:

I have a worksheet that I want to hide all the tabs other than "Policy
information"
What is wrong with the below code. The macro doesn't seem to recognize the
line

If sheet.Name < "Policy information" Then

correctly

Sub visible_sheets()
Dim sheet As Worksheet
For Each sheet In Worksheets
If sheet.Name < "Policy information" Then
Sheets.Visible = False
End If
Next
End Sub


--

Dave Peterson


All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com