left x amount of letters in a sheet foir macro

maxzoran

Board Regular
Joined
Feb 1, 2008
Messages
63
I am trying to set a worksheet that is imported in as:

SchedulerBoard124536

where the numbers after the SchedulerBoard are randomly generated. I'm thinking maybe using the left function to specify 14 characters? I'm not sure how to code it for the macro to only look for the text SchedulerBoard. Help is greatly appreciated
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
here's my current code

Code:
Set shtSB = Sheets("SB")
Right now I'm having to rename SchedulerBoard1246545 (the number at the end is randomly generated) SB so the macro will recognize to pull data from that sheet. I would like to not have to rename the sheet and just have the macro look for the sheet that contains the text "SchedulerBoard" and ignore the numbers
 
Upvote 0
Try:

Code:
Dim ws as Worksheet
Dim ShtSB as Worksheet
For Each ws in ActiveWorkbook.Worksheets
    If Left(ws.Name, Len("SchedulerBoard")) = "SchedulerBoard" Then
        Set ShtSB = ws
        Exit For
    End If
Next ws
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,834
Members
452,947
Latest member
Gerry_F

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