Hello Mark,
Here is the revised macro and it has been added to the attached workbook.
Sub JournalReceipts()
Dim Area As Range
Dim Cell As Range
Dim Data(1 To 1, 1 To 7) As Variant
Dim DstRng As Range
Dim DstWks As Worksheet
Dim I As Long
Dim R As Long
Dim RngEnd As Range
Dim SrcRng As Range
Dim SrcWks As Worksheet
Set DstWks = Worksheets("Yearly Totals")
Set SrcWks = Worksheets("Cash Receipts")
Set SrcRng = ThisWorkbook.Names("Receipts").RefersToRange
Set DstRng = DstWks.Range("B3:H3")
Set RngEnd = DstWks.Cells(Rows.Count, DstRng.Column).End(xlUp)
Set DstRng = IIf(RngEnd.Row < DstRng.Row, DstRng, RngEnd.Offset(1, 0))
Data(1, 2) = "Cash"
Data(1, 3) = " ----------"
Data(1, 5) = " ---"
Data(1, 7) = " ---"
For Each Area In SrcRng.Areas
Data(1, 1) = Area.Item(1).Offset(-2, 0).Text
For I = 1 To 14
If Not IsEmpty(Area.Item(I)) Then
Data(1, 4) = Area.Item(I).Value
Code = Area.Item(I).Offset(0, -1).Value
Data(1, 6) = Switch(Code = "", "Food", Code = "fo", "Front Office", _
Code = "h", "Hardware", Code = "c", "CTP", _
Code = "o", "Other")
DstRng.Offset(R, 0).Value = Data
R = R + 1
End If
Next I
Next Area
End Sub
Bookmarks