dim and set in one line

Amateurhr

Active Member
Joined
Dec 26, 2011
Messages
343
Any idea how to do this in one line? I've seen it done before but cannot find the syntax again. Why do people separate it into 2 lines if 1 is sufficient?

Code:
dim dict As dictionary
Set dict = New dictionary
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Code:
    Dim dic As New Scripting.Dictionary
 
    Set dic = Nothing
    MsgBox dic Is Nothing
Doing this automatically creates an instance of a dictionary when it appears in an executable line of code, so the MsgBox always returns false.

I recommend against using it.
 
Upvote 0

Forum statistics

Threads
1,211,710
Messages
6,103,448
Members
447,865
Latest member
Devsito

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