SET UP:
I've created a user form where a person can enter information such as the date, explanation of transaction, amount, recurrence pattern (weekly, bi-weekly, or monthly), and number of recurrences. That information is then transferred to the worksheet, changing the date by the corresponding interval for the given number of recurrences.
This is meant to be used in a budgeting sheet where the user expects a recurring income (e.g. bi-weekly work cheques) or expense (e.g. monthly rent).
PROBLEM:
For each transaction, the date ends up being thrown off from the original if the number of recurrences is high.
For example:
Entering:
2011-11-29, Test (as explanation), 85 (as amount), weekly, 9 recurrences
Gives: Proper information except the dates. The dates I end up with are:
2011-11-29, 2011-12-03, 2011-12-06, 2011-12-10, 2011-12-13, 2011-12-17, 2011-12-20, 2011-12-24, 2011-12-27
However, when I put in a lower number of recurrences (say 5), I get the right dates.
CODE:
Here is a brief example of the code for a weekly recurrence transaction:
Do
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1,0).Row
If optionWeek = True Then
If Me.textNumberRecurrences.Value - 1 > 0 Then
ws.Cells(iRow, 1).Value = ws.Cells(iRow, 1).Value + _
Day(7 * (Me.textNumberRecurrences.Value - 1) + 1)
End If
End If
[code for other possible recurrence patterns (bi-weekly, monthly)]
[code for entering other user input (explanation, amount)]
Me.textNumberRecurrences.Value - 1
Loop Until Me.textNumberRecurrences = 0
[code to re-order transactions from earliest to latest]
Feel free to ask me questions for more clarification of the problem if needed.
I've created a user form where a person can enter information such as the date, explanation of transaction, amount, recurrence pattern (weekly, bi-weekly, or monthly), and number of recurrences. That information is then transferred to the worksheet, changing the date by the corresponding interval for the given number of recurrences.
This is meant to be used in a budgeting sheet where the user expects a recurring income (e.g. bi-weekly work cheques) or expense (e.g. monthly rent).
PROBLEM:
For each transaction, the date ends up being thrown off from the original if the number of recurrences is high.
For example:
Entering:
2011-11-29, Test (as explanation), 85 (as amount), weekly, 9 recurrences
Gives: Proper information except the dates. The dates I end up with are:
2011-11-29, 2011-12-03, 2011-12-06, 2011-12-10, 2011-12-13, 2011-12-17, 2011-12-20, 2011-12-24, 2011-12-27
However, when I put in a lower number of recurrences (say 5), I get the right dates.
CODE:
Here is a brief example of the code for a weekly recurrence transaction:
Do
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1,0).Row
If optionWeek = True Then
If Me.textNumberRecurrences.Value - 1 > 0 Then
ws.Cells(iRow, 1).Value = ws.Cells(iRow, 1).Value + _
Day(7 * (Me.textNumberRecurrences.Value - 1) + 1)
End If
End If
[code for other possible recurrence patterns (bi-weekly, monthly)]
[code for entering other user input (explanation, amount)]
Me.textNumberRecurrences.Value - 1
Loop Until Me.textNumberRecurrences = 0
[code to re-order transactions from earliest to latest]
Feel free to ask me questions for more clarification of the problem if needed.
Last edited: