Complete macro noob and not sure what to do. I have borrowed a macro from this forum to select a tab based on the worksheet name
It is able to search for the Apple string.
However, how do I modify this so that it allows for "Pear" as well? I tried the following:
and ended up with a debug error (runtime 13 - type mismatch)
Is there a way to stick the "Apple" or "Pear" search together? I just want to select the worksheet if it contains either string.
VBA Code:
Sub Macro1()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "* Apple" Then
ws.Select
Exit For
End If
Next ws
End Sub
It is able to search for the Apple string.
However, how do I modify this so that it allows for "Pear" as well? I tried the following:
Code:
If ws.Name Like "* Apple" Or "* Pear" Then
and ended up with a debug error (runtime 13 - type mismatch)
Is there a way to stick the "Apple" or "Pear" search together? I just want to select the worksheet if it contains either string.