![]() |
Using Worksheet Code Names
Hello,
I would like to hide all sheets in a workbook except a sheet with Code Name wksAdmin. The following code produces error message: object does not support this property or method. I know i'm referencing wksAdmin incorrectly, but not sure why. thanks for any help. Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet < wksAdmin Then wksSheet.Visible = False End If Next wksSheet End Sub |
Using Worksheet Code Names
Sub HideAllSheetsExceptAdmin()
Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet.Name < "wksAdmin" Then wksSheet.Visible = xlSheetHidden End If Next wksSheet End Sub "Jake" wrote: Hello, I would like to hide all sheets in a workbook except a sheet with Code Name wksAdmin. The following code produces error message: object does not support this property or method. I know i'm referencing wksAdmin incorrectly, but not sure why. thanks for any help. Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet < wksAdmin Then wksSheet.Visible = False End If Next wksSheet End Sub |
Using Worksheet Code Names
Hi
Try this: Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet Dim wAdm As String wAdm = wksAdmin.Name For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet.Name < wksAdm Then wksSheet.Visible = False End If Next wksSheet End Sub Regards, Per On 17 Dec., 20:16, Jake wrote: Hello, I would like to hide all sheets in a workbook except a sheet with Code Name wksAdmin. *The following code produces error message: *object does not support this property or method. *I know i'm referencing wksAdmin incorrectly, but not sure why. *thanks for any help. Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets * * If wksSheet < wksAdmin Then * * * * wksSheet.Visible = False * * End If Next wksSheet End Sub |
Using Worksheet Code Names
If wksSheet.Name < wksAdmin.Name Then
wksSheet.Visible = False End If You need apples and apples. "Jake" wrote: Hello, I would like to hide all sheets in a workbook except a sheet with Code Name wksAdmin. The following code produces error message: object does not support this property or method. I know i'm referencing wksAdmin incorrectly, but not sure why. thanks for any help. Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet < wksAdmin Then wksSheet.Visible = False End If Next wksSheet End Sub |
Using Worksheet Code Names
thanks!
"Per Jessen" wrote: Hi Try this: Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet Dim wAdm As String wAdm = wksAdmin.Name For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet.Name < wksAdm Then wksSheet.Visible = False End If Next wksSheet End Sub Regards, Per On 17 Dec., 20:16, Jake wrote: Hello, I would like to hide all sheets in a workbook except a sheet with Code Name wksAdmin. The following code produces error message: object does not support this property or method. I know i'm referencing wksAdmin incorrectly, but not sure why. thanks for any help. Sub HideAllSheetsExceptAdmin() Dim wksSheet As Worksheet For Each wksSheet In ActiveWorkbook.Worksheets If wksSheet < wksAdmin Then wksSheet.Visible = False End If Next wksSheet End Sub |
All times are GMT +1. The time now is 02:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com