revisions: if there is already a posting for the given category it searches for the next one. If cannot find one not having a post, it sticks the payment to the last one in the category. The accumulated expenses was added as part of the testing.
Sub post()
Dim ck, bg As Worksheet
Set ck = Sheets("Checking")
Set bg = Sheets("Budget")
r = 3
While Cells(r, 3) <> ""
If ck.Cells(r, 8) = "" Then
m = Month(ck.Cells(r, 1))
d = Day(ck.Cells(r, 1))
' ck.Cells(r, 9) = m
ct = ck.Cells(r, 3)
With bg.Range("b:b")
Set c = .Find(ct, LookIn:=xlValues)
If Not c Is Nothing Then
fa = c.Address
r2 = c.Row
Do
dt = (bg.Cells(c.Row, 1))
dm = Month(dt)
r3 = r2
r2 = c.Row
Set c = .FindNext(c)
Loop While (bg.Cells(r2, 8) <> "" Or dm <> m) And fa <> c.Address
If dm <> m Then
r2 = r3
End If
bg.Cells(r2, 8) = bg.Cells(r2, 8) & ", " & m & "/" & d
bg.Cells(r2, 9) = bg.Cells(r2, 9) + ck.Cells(r, 5)
ck.Cells(r, 8) = "**"
End If
End With
End If
r = r + 1
Wend
End Sub
Bookmarks