Worksheet variable question

lownote14

New Member
Joined
Apr 7, 2011
Messages
19
I tried googling this with no success so I thought I would bring it to the attention of you fine excel gurus.

I need to know if you can call a worksheet, first by it's given name, instead of sheet 1. And two, use a variable to call that worksheet.

For example I have a data validation list of names, like Sam, Fred, Mike, and Roger. Those names correspond to worksheet with the name Sam, Fred, Mike and Roger. I would like it to looks something like this:

Code:
'This variable is what will contain the name (ie Sam, Fred etc...) _
'from the data validation.
Dim OCC as string
worksheet(OCC).range("a1").value
...

let me know if this doesn't make any sense.
 
That means that the sheet name in B2 doesn't exist. Check for leading or trailing spaces or mis-spellings in both the validation list and the sheet names.

The code works for me, by the way.
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
:eeek: I feel like such a fool. I have two words that have very similar names but haven't gotten to creating that sheet yet so it kept referencing a sheet that did not exist.:eeek:

Many apologies for my simple solution, and thanks to you for holding my hand through this process.:biggrin::biggrin:
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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