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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,215,350
Messages
6,124,430
Members
449,158
Latest member
burk0007

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