VBA - Search Worksheet Tabs by partial name

rmfrase

Board Regular
Joined
Jul 6, 2006
Messages
128
I have a spreadsheet that is sent to me monthly. here is the issue I'm facing:

Each workbook contains multiple tabs.
The position of those tabs may be different positions when received.
The part of each tab's naming convention does not change, while the rest of the tabs' name contains random information.

My question:
Is it possible to to search/find the tab based on part of the name?

example: Name on tab:
Pivot Table Data June 2011

Search for: Pivot


Thanks for your help.
-Robert
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try like this

Code:
Sub test4()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
    If ws.Name Like "Pivot*" Then
        ws.Select
        Exit For
    End If
Next ws
End Sub
 
Upvote 0
If I wanted to create a loop, where if it's not "pivot", it searches another tab name until if finds the right one and then ends loop?

Sub test4()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
If ws.Name Like "Pivot*" Then
ws.Select
Exit For
End If
Next ws
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,038
Messages
6,128,447
Members
449,453
Latest member
jayeshw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top