I am trying to use a for loop to create a series of data, assign that data and the index number to an array, and then send that array to a worksheet.
This sends only the data and not the index number to the array.
Option Explicit
Sub MonthlyObligation()
Dim ws As Worksheet
Set ws = Sheets("Page 1")
' 1. Define the array
Dim arr() As Variant
' 2. Generate Data with for Loop
' 2a. Determine the number of rows in the array
Dim BaseTerm As Integer
Dim OptionCount As Integer
Dim OptionTerm As Integer
BaseTerm = ws.Range("LeaseTerm").Value
OptionCount = ws.Range("RenewalOptions").Value
OptionTerm = ws.Range("TermPerOption").Value
Dim TotalTerm As Long
TotalTerm = ((BaseTerm + (OptionCount * OptionTerm)) / 12)
' 2b. Redefine the array to the row count
ReDim arr(1 To TotalTerm, 1)
' 2c. Create Data for the array
Dim MonthlyBaseRent As Double, AnnualRiser As Double, currentRow As Long
MonthlyBaseRent = ws.Range("BaseRent").Value
AnnualRiser = ws.Range("RentIncrease").Value
Dim i As Long, j As Long
For i = 1 To TotalTerm
For j = 1 To 1
MonthlyBaseRent = (MonthlyBaseRent * (1 + AnnualRiser))
' 2a. Store the Data in the Array
arr(i, j) = MonthlyBaseRent
Debug.Print arr([i], [j])
Next j
Next i
End Sub
i?ReDim arr(1 To TotalTerm, 1)is the same asReDim arr(1 To TotalTerm, 0 To 1)- is that what you want? If you want to store two values pr row thenReDim arr(1 To TotalTerm, 1 To 2)might be better.For j = 1 To 1. If this is deliberate, it is totally unnecessary, as it executes only once. This would also mean that a single dimensional array would suffice.