Declaring Variables

kelly mort

Well-known Member
Joined
Apr 10, 2017
Messages
2,169
Office Version
  1. 2016
Platform
  1. Windows
Hello Geniuses,
I need clarification to which variable types to use: Integer vs Long. When do I use long? I am confused. I am thinking maybe where I have used long, I may be using Integer instead.
Thanks in advance.
Kelly.

PS.
Also when I declare almost all my variables at the top of my module, I understand these variables are held in memory as long as the module is active. Does this practice have any downside on memory?
Thanks again
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
On modern computers Integers are stored as Long Integers and so there is no advantage of using Integers unless you specifically want to restrict the range (there is even some evidence that even when it is in the range of an Integer it is more efficient to use Long now).

I only ever use Long these days.
Also when I declare almost all my variables at the top of my module, I understand these variables are held in memory as long as the module is active. Does this practice have any downside on memory?
If it does it would be miniscule but someone else might have some more enlightenment on this subject.
 
Last edited:
Upvote 0
@mark
Okay thank you for making it clear. I really appreciate it.
Regards.
Kelly.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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