VBA to change mass formulas
Here is a correction that allows you to easily adjust.
Sub AddFormulas()
Dim i As Long, numClasses As Long
Dim numStudents As Long
Dim StepValue As Long
NumClasses = 17 ' now 17
numStudents = 100 ' now 100
StepValue = NumClasses + 2
For i = numStudents * StepValue + 2 To 4 Step -StepValue
Range("B" & i).Formula = _
"=SUM(AB" & i - 1 & ":AB" & i - _
NumClasses & ")"
Next i
End Sub
--
Regards,
Tom Ogilvy
"David" wrote in message
...
Tom Ogilvy wrote
Misread - I thought the formulas were in contiguous cells in column B
- like what you showed.
That's ok. I'm not always as clear as I ought to be. I went with Bob's
less
elegant, but concise and effective loop. Thanks for jumping in, anyway.
--
David
|