A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I have the impression that dimension “integer” might run code faster than “long”.
At the machine instruction level, it no longer makes any difference. That used to be true of PCs before the 1990s.
I cannot speak for VBA with impunity. Since VBA is an interpreter to some degree, it is unclear if and how much code is compiled into machine language.
Performance measurements are tricky due to idiosyncracies that I attribute to VBA as well as external factors beyond our control (interrupts, cache misses, VBA loop overhead, etc), all of which cause a great deal of variability. And of course, it might vary from one computer to another.
Ironically, on my computer, simple type Integer arithmetic (x=x+1) seems to be about 21% slower(!) than type Long arithmetic.
(EDIT.... I'm skeptical of that conclusion. But even if it's right, I doubt that you will see any significant performance difference if you change all type Integer to type Long. Any integer calculation is probably a small percentage of the overall execution time. And that's really the point.)
Of course, the bigger difference is storage space. But that should matter only if you have humongous arrays (read: multi megabytes),
IMHO, the most important thing is reliability and flexibility of the code. Sooner than later, "integer overflow" will come to haunt you, if you use type Integer.
Aside.... It is also important to use type Double instead of type Single. Again, there is no performance difference at the machine instruction level. But there is a precision issue that will bite you if/when you store a type Single value into an Excel cell. For example, Cells(1,1) = CSng(1.23) results in the value 1.23000001907348.
Not sure how I can use any designation other than “row” (versus “r”)?
Are we talking about the same thing?
I was merely commenting about the choice of variable names, not the concept of a row number.
Obviously, we are free to choose (almost) any name for a variable.
I am merely suggesting that we avoid names that VBA uses for (common) properties, even if VBA itself is okay with it.
Sigh, VBA does not make that easy to do. When I suspect that my variable name might be a VBA property name, I test it by entering a simple statement, for example x = row (lowercase). When VBA changes "row" to "Row" automagically, I know that VBA uses that name in some context.
But I draw the line at "z". So at the end of the day, it is just a matter of personal preference.