Working my way through the Excel VBA for dummies book which is quite fun, inputting one of the exercises as follows:
Code
Sub FillRangeWithRandomNumbers()
Dim Col As Long
Dim Row As Long
For Col = 1 To 5
For Row = 1 To 12
Cells(Row, Col) = Rnd
Next Row
Next Col
End Sub
This works just as I'd expect it to. I then decided to spice it up a little as follows:
Code
Sub FillRangeWithRandomNumbersEnhanced()
Dim Col As Long
Dim Row As Long
Dim RunTot As Integer
For Col = 2 To 11
For Row = 2 To 11
Cells(Row, Col) = WorksheetFunction.RandBetween(1, 100)
Range("K14") = RunTot = Cells(Row, Col) + RunTot
Next Row
Next Col
End Sub
Display More
This, sort of does as I'd expected but returns FALSE in K14 rather than the total of the random numbers. Can someone please explain to me what I'm doing wrong?