Hi,
I am using the following VBA code to simulate the rolling of dice. The code puts the random numbers in the next unused row in columns AE and AF respectively.
I would to use VBA to take the sum of each pair of values in columns AE and AF that are in the same row. The would be placed in the next unused row in column AG. I tried modifying the code used in the Random sub to do this, but received an error. The code I used is:
Does anyone have a suggestion to fix my errant code?
Thanks,
Art
I am using the following VBA code to simulate the rolling of dice. The code puts the random numbers in the next unused row in columns AE and AF respectively.
Code:
Sub Random1()
Dim i As Integer
For i = 1 To Range("AD2")
Range("AE" & Rows.Count).End(xlUp).Offset(1, 0).Formula = Int(Rnd * 6 + 1)
Range("AF" & Rows.Count).End(xlUp).Offset(1, 0).Formula = Int(Rnd * 6 + 1)
Next i
End Sub
I would to use VBA to take the sum of each pair of values in columns AE and AF that are in the same row. The would be placed in the next unused row in column AG. I tried modifying the code used in the Random sub to do this, but received an error. The code I used is:
Code:
Sub Sum()
Range("AG" & Rows.Count).End(xlUp).Offset(1, 0).Formula = Range("AE") + Range("AF")
End Sub
Does anyone have a suggestion to fix my errant code?
Thanks,
Art