Thread: If Then
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default If Then

Sometimes using the "select case" syntax makes things easier to see.

Option Explicit
Sub testme()
With ActiveSheet
Select Case LCase(.Name)
Case Is = "sheet1", "sheet2", "sheet3"
.Rows(16).Hidden = True
Case Is = "sheet4"
.Rows(4).Hidden = True
Case Else
'do nothing
End Select
End With
End Sub

ps. this is a text only newsgroup--please post in plain text (not HTML and no
attachments).

Dean wrote:

Can someone give me the exact code for the following general situation:

If the active worksheet when a macro is called is sheet 1 or sheet2 or sheet3,
then hide row 16. Or, if sheet 4, hide row 18. If any other sheet, don't
hide anything - that I suppose requires no text!

Thanks!
Dean


--

Dave Peterson