Worksheet Variable

Xenocity

New Member
Joined
Jul 6, 2011
Messages
7
HI,

I have tried looking at all the examples of how to create a formula in VBA that has the worksheet defined as a variable that I can easily change for each report I need.

I don't know how to define this at the top of my module.

Range("B486").Select
ActiveCell.FormulaR1C1 = _"=IF('2012master'!R[-483]C[82]="""","""",VLOOKUP(""Y"",'2012master'!R[-483]C[82]:R[-483]C108,24,FALSE))"

I am looking for something at the top similar to:

set ws = '2012master'

so that all the formulas on the vba will use the workshee that I define.

Secondly, I wanted to make the process easier for the user so that they could choose the worksheet from a user form to populate the specific worksheet being used for the variable if this is possible.

Thank you in advance.
 
One last question, Can I hide any of the worksheet from not populating the combo box, it would only be 4 of the sheets. Not a problem just more aesthetically pleasing.

Thank you again Ruddles
 
Upvote 0

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Instead of this:-
Code:
    UserForm1.ComboBox1.AddItem ws.Name
do this:-
Code:
  select ws.name
    case "this_sheet", "this_other_sheet"
    [COLOR=green]  ' do nothing[/COLOR]
    case else
      UserForm1.ComboBox1.AddItem ws.Name
  end select
 
Upvote 0
That worked as well.

If anyone else is looking I had to use:

Select case ws.name

in order for it to function but after that it worked!

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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