another way to do Dim a worksheet?

birdieman

Well-known Member
Joined
Jan 13, 2016
Messages
551
I am still relatively new to VBA so my question may not be stated with correct words. One of my worksheets is labeled ufd. Is this the correct way to set it up to be able to then refer/use it in code?
Code:
Dim ufd As Worksheet
Set ufd = Sheets("ufd")

The above works fine, but I wondering if the word "set" is correct because I have begun to have some Excel crashing problems and am checking all the little stuff. One of the Excel -type errors is "do not set the value of a microsoft object......." This may have nothing to do with my code above but was checking everything.

So, back to the question: Is the above the correct way to Dim a worksheet, or is there a simpler/better/shorter way?
thanks
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Yes that is correct.
 
Upvote 0
Yes, that is correct.
When setting variables equal to objects (like workbooks, worksheets, and ranges), you use "Set".
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,812
Members
449,048
Latest member
greyangel23

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