Boolean / If evaluation time relative to other functions

Amateurhr

Active Member
Joined
Dec 26, 2011
Messages
343
This is more a general programming question but often I try to abstract the capabilities of a function by allowing it to take optional parameters that give the function flexibility in how you feed it incoming data.

In order for this to work, I often will be doing evaluations of the parameters, and in particular booleans. Often I'm tempted to create separate functions that will avoid a boolean evaluation for speed purposes, but I realize this might be an unnecessary if booleans are evaluated an order of magnitude faster than other functions.

Consider:
Code:
If varBoolean then 
'do something
else
'do something
end if

Any thoughts on how fast this is to evaluate vs. other excel functions?
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

kpark91

Well-known Member
Joined
Jul 15, 2010
Messages
1,582
It really depends on how your boolean value is used.
If it's something that can be avoided, you should not use it (which is the best way to reduce resources)

If you want comparison in speed for IF against all the other comparison methods, I would suggest using anything that is easier to read.
Each case is different for comparison so you can safely say all the other methods are the same in terms of speed.

The only thing I would suggest would be using Byte for comparison rather than Boolean as Byte takes up one byte while Boolean takes up two bytes in VBA (which is... odd).
 

Watch MrExcel Video

Forum statistics

Threads
1,122,652
Messages
5,597,373
Members
414,139
Latest member
okela0

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
Top