Possible? Declaring variables of the same nature on one line

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi Martin

Not that I'm a fan of these, but just to complete the options, 2 more:

1 - You can use a type-declaration character. These are suffixes you add to the variable name that define its type. For ex., for a string it's the "$". Ex.:

Code:
Dim T1$, T2$, T3$

2 - if you are really consistent in naming variables (as you should) you can also define type prefixes. For ex., in my case, I always prefix a string variable name with the letter "s". In this case I could (but I don't) define de "s" as a prefix for strings at the beginning of the module and use it in the variable declarations. Ex.:

Code:
Option Explicit
DefStr S
...
Dim sName1, sName2
...

As I said, I'm a fan of neither of these 2. I use the "As" syntax.
 
Upvote 0

Forum statistics

Threads
1,224,603
Messages
6,179,853
Members
452,948
Latest member
UsmanAli786

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