Select Case from Dynamic Range

bujaman

Board Regular
Joined
Apr 2, 2009
Messages
56
I have a workbook with multiple sheets, some of which end in a 4 character string that tells the code to go and grab information out of that sheet. I have the following basic code structure and it is working great. The problem is that the user may need to add new sheets that meet the "Case" criteria. I want to pull the "Case" values ( "C.01", "C.02", etc) from a range in a worksheet instead of hard coded. Is there a way to do this, or do I need to modify the code each time someone adds a new sheet? Nay help is much appreciated, thanks!

Code:
For Each sh In wkbSource.Worksheets
   Select Case Left(sh.Name, 4)

     Case "C.01", "C.02", "D.01"   'this is where i want to pull information from a range of cells instead of hard coding.  

        'do stuff

    End Select
Next sh
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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