Performance test regarding variable declarations. Does Variable declaration matters nowadays?

Luthius

Active Member
Joined
Apr 5, 2011
Messages
324
Guys
I was looking forward a Speed Test or Performance test where is possible measure a code running with declared variables and other without variable declaration.

I saw a lot of discussions about this subject and it always goes to a Best Practice point of view rather then "performance" or error management.
Okay, in my projects I always declare the variables and try my best to proper set the most memory optimized type as possible.
Even some object type I guess is NOT "mandatory" because the VBE "guess" and compile it.

If someone has some speed test or performance test or something that can share it, where shows that it goes beyond best practices, I mean, declare variables really matters for the computer's capacity nowadays (memory, processor, etc.)
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Not really speed wise unless you have huge data , it is just on a very rare occasion VBA can misinterpret what you want if the value changes from one data type to another (say your initial value was a Long and then you started using Decimals).
The main advantage of declaring your variables is you can use Option Explicit to pick up on typo's.
 
Upvote 0
In other words doesn't matter declaring the variables or not. For coding sake I mean.

But I'm curious because variant types demand more usage of memory, so it can jeopardize the speed, right?
 
Upvote 0
It affects the speed but it is a case of how noticeable it is. As I stated the main advantage of declaring them these days is debugging.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,684
Members
448,977
Latest member
dbonilla0331

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