Set Command For a Worksheet

MikeG

Well-known Member
Joined
Jul 4, 2004
Messages
845
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
I have a cell in my spreadsheet that I have given the range name "Sh1_Name". Currently the value in the cell is the word "Product".

In my macro I want to tell Excel to set OpsSht(1) to the "Product" worksheet, but cannot come up with the right code. I have...

Dim OpsSht(10) As Worksheet
Set OpsSht(1) = Sheets(Range("Sh1_Name"))

... but the second line does not work. Could someone help?

Thanks,

MikeG
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Mike,

Are OpsSht 10 and OpsSht 1 the same thing?

Dim OpsSht1 as Worksheet
Set OpsSht1 = Worksheets("Product")
 
Upvote 0
Mike,

Are OpsSht 10 and OpsSht 1 the same thing?

Dim OpsSht1 as Worksheet
Set OpsSht1 = Worksheets("Product")

Thanks Dryver.

Actual they are not. I have 9 other sheets so for example I want OpsSht(1) as "Product", OpsSht(2) as "Customer" and so on. But I want the user to be able to define these names in the spreadsheet, not in the macro - because the names can change from time to time.

Mike
 
Upvote 0

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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