I have implemented this method to multiply every array element by a number held in a variable, it works, but I believe it is terribly slow. Is there an accepted "fastest" way to multiply every element in a range by a constant? Or at least one which is not as slow? I have to do this 10 times and it takes a couple of minutes. This is my slow solution:
MultFactor = 10
For Each cell In Sheet1.Range("B3:B902")
cell.Value = cell.Value * MultFactor
Next cell
The solution cited here (with 14 likes):
Multiply Entire Range By Value?
multiplies by a constant (not a variable), but even if I use this code as is (except for changing the range from "A1:B10" to "B3:B902"),
Dim rngData As Range
Set rngData = Sheet12.Range("B3:B902")
rngData = Evaluate(rngData.Address & "*2")
I get a non-sense answer. My original values in B3:B902 are zero for the first 100 elements or so and then increase a bit and finally decrease and have another run of zeros, but what ends up in my range is a series of numbers that clobbers everything in my range. It begins at -224.5 and decreases by 0.5 all the way to the last cell.
-224.5
-224.0
-223.5
etc
Even if that worked, how would I modify it to use the variable MultFactor? I must be doing something wrong here, but don't know what it is. I appreciate the help if someone can spot what I'm doing wrong.