Domenic said:
I take it the reason no one has come forward to help with this is
because no one here has an existing macro that comes close to what I'm
looking for, and writing one would be somewhat complex and very time
consuming. If this is the case, I can definitely understand. Thanks
all the same!
Thinking about it, it's not all that difficult, but it takes some
setting up. The following is a quick and dirty attempt. It assumes that
you open your workbook at least once per month.
One way would be to put, on sheet "Auto", the following headers:
A1: Description
B1: Source
C1: Day of Month
D1: Debit Amount
E1: Credit Amount
F1: 1 July 2004
Enter your auto data.
Then put this code in your ThisWorkbook code module:
Private Sub Workbook_Open()
Auto_Update
End Sub
and put something like this in a regular code module:
Public Sub UpdateAutoItems()
Dim nLastCol As Long
With Sheets("Auto")
With .Cells(1, .Columns.Count)
If Not IsEmpty(.Value) Then
MsgBox "Auto Data range Full"
Exit Sub
Else
If IsEmpty(.Offset(0, -1).Value) Then
nLastCol = .End(xlToLeft).Column
Else
nLastCol = .Column
End If
End If
End With
If .Cells(1, nLastCol).Value <> DateSerial( _
Year(Date), Month(Date), 1) Then
EnterItems nLastCol, 32
nLastCol = nLastCol + 1
.Cells(1, nLastCol).Value = DateSerial( _
Year(Date), Month(Date), 1)
End If
EnterItems nLastCol, Day(Date)
End With
End Sub
Public Sub EnterItems(nCol, nAsOfDate As Long)
Dim vEntry As Variant
Dim rCell As Range
Dim dEntryDate As Double
With Sheets("Auto")
For Each rCell In .Cells(2, nCol).Resize( _
.Cells(.Rows.Count, 1).End(xlUp).Row - 1, 1)
If IsEmpty(rCell.Value) Then
If .Cells(rCell.Row, 3).Value <= nAsOfDate Then
dEntryDate = CDate(.Cells(1, nCol) + _
.Cells(rCell.Row, 3) - 1)
ReDim vEntry(1 To 6)
With .Cells(rCell.Row, 1).Resize(1, 5)
vEntry(1) = Format(dEntryDate, "dd mmm yyyy")
vEntry(2) = .Item(2)
vEntry(3) = .Item(1)
vEntry(4) = .Item(4)
vEntry(5) = .Item(5)
End With
With Sheets("Sheet1")
With .Cells(.Rows.Count, _
1).End(xlUp).Offset(1, 0)
.Resize(1, 5).Value = vEntry
.Offset(0, 5).FormulaR1C1 = _
"=R[-1]c[]-r[]c[-2]+r[]c[-1]"
End With
End With
rCell.Value = "X"
End If
End If
Next rCell
End With
End Sub
The sub will then keep track of entered auto values for 251 months (If
you're still using it after nearly 21 years, the sub tells you the data
range is full).
NOTE: This has been only lightly tested.