Thread: Type mismatch?
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Type mismatch?

John,

Try this

Public Sub HideSelectedSheets()
Dim Wsh As Worksheet
For Each Wsh In ActiveWorkbook.Worksheets
If UCase(Wsh.Range("G1").Value) = "HIDE" Then
Wsh.Visible = xlSheetHidden
End If
Next
End Sub

If it works, it means that you have another type of sheet, such as a chart,
and as you defined Wsh as a worksheet, it mis-matches. You can safely ignore
these, as they won't have a cell on anyway.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Wirt" wrote in message
...
When I run this code, I get an error="Type mismatch." How come?

Public Sub HideSelectedSheets()
Dim Wsh As Worksheet
For Each Wsh In ActiveWorkbook.Sheets
If UCase(Wsh.Range("G1").Value) = "HIDE" Then
Wsh.Visible = xlSheetHidden
End If
Next
End Sub

Thank you.

John Wirt