Quick and, I assume, relatively easy question regarding VBA in Excel. I'm writing my first nested loop and I'm running into the problem where my second increment overwrites the first one. Here's the code:
Sub RandNumRang()
Dim i As Integer, Row As Integer, Col As Integer
Dim j As Integer
Dim LastRow As Long
Dim NoRows As Integer
Dim MinNum As Double, MaxNum As Double
Dim NumFormula As String
Col = 1 'Write random numbers on Column A
'Get the range and number of random values needed
For j = 3 To 4
NoRows = ActiveSheet.Range("G" & j).Value 'No of random values needed
MinNum = ActiveSheet.Range("E" & j).Value 'Min Range
MaxNum = ActiveSheet.Range("F" & j).Value 'Max Range
NumFormula = "=RANDBETWEEN(" & MinNum & "," & MaxNum & ")" 'Generate between Range
i = 0
For Row = 2 To NoRows + 1
i = i + 1
ActiveSheet.Cells(Row, Col).Value = i 'ID
ActiveSheet.Cells(Row, Col + 1).Formula = NumFormula 'Random Value
ActiveSheet.Cells(Row, Col + 2).FormulaR1C1 = "=TIME(0,0,RC[-1])" 'Convert to time
Next Row
Next j
End Sub
I'm trying to generate a set of random time intervals. The code does exactly what I want it to do except my values are being overwritten. The j loop will eventually have more than 2 increments but this code will have the same overwriting problem regardless. I'm pretty sure it has something to do with me specifying
For Row=2 To NoRows + 1
as the starting point of the nested loop but again this being my first run at a VBA script I figured I'd reach out because every fix I've tried has failed. Thanks in advance, and let me know if you need any further details.
Also, I have attached a screenshot of the worksheet for reference:

IDvalues in column A?