Global procedures

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
592
Do I have to dimension a global variable as string, integer etc.?

I Have:

Global my_age , Continue, Street

Should I have:

Global my_age as interger, Continue as string, Street as string
Would the second way use less memory?
 
Last edited:

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,412
Office Version
365
Platform
Windows
Would the second way use less memory?
Yes, because all undeclared variables and variables declared without a data type default to the Variant type, which uses the most memory.

It is always a good idea to declare all your variables, and give them a data type.

If you place "Option Explicit" at the top of your code, it will force you to declare all your variables. This is a great tool to help with debugging, and will quickly find any typos you may have in variable names.
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
53,412
Office Version
365
Platform
Windows
You are welcome.
 

Fire_Chief

Well-known Member
Joined
Jun 21, 2003
Messages
592
Do I have to use the Dim statement or can I just use..... Global street as string, my_age as interger
 

Watch MrExcel Video

Forum statistics

Threads
1,099,086
Messages
5,466,544
Members
406,486
Latest member
varmehta

This Week's Hot Topics

Top