View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
DaveO[_2_] DaveO[_2_] is offline
external usenet poster
 
Posts: 46
Default If sheet name contains 'A' run macro1, if 'B' run macro 2?

Hi, Dan-
This code will do it:

Sub AllTabs()
Dim SheetName

For Each SheetName In Sheets
If InStr(1, SheetName.Name, "A") 0 Then
Macro_A
goto ReStart:
end if

If InStr(1, SheetName.Name, "B") 0 Then
Macro_B
goto ReStart:
end if

ReStart:
Next SheetName
End Sub

Substitute your macro names for Macro_A and Macro_B.

This code will run against ALL tabs in the workbook, and hidden tabs
may cause a runtime error.

Dave O