[FONT=Verdana][COLOR=black][COLOR=black][FONT=Verdana]Sub AddTotals()[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]'This macro will seperate the Receipt Types and then Add the Subtoatals (BOLD & Red Font)[/FONT][/COLOR]
[COLOR=black][FONT=Verdana]Dim LR As Long, i As Long[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]Dim x As String, y As String, z As String[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]LR = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]For i = LR To 3 Step -1[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]Status = Cells(i, "F")[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] If Cells(i, "F") <> Cells(i + 1, "F") And Cells(i + 1, "F") <> "" Then[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Rows(i + 1 & ":" & i + 3).Insert Shift:=xlDown[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End If[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]Next i[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]LR = ActiveSheet.Range("F" & Rows.Count).End(xlUp).Row + 1[/FONT][/COLOR]
[FONT=Verdana][COLOR=black] Rows(LR & ":" & LR + 2).Insert Shift:=xlDown[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]Appy = WorksheetFunction.CountIf(Range("F:F"), "Applied")[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]UnAp = WorksheetFunction.CountIf(Range("F:F"), "Unapplied")[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]Unid = WorksheetFunction.CountIf(Range("F:F"), "Unidentified")[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]'This will prevent an error if there are no Applied Receipts[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]If Appy <> 0 Then[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC1 = Cells.Find("Applied", After:=ActiveCell, SearchDirection:=xlNext).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC1 = Range(MCC1).Offset(Appy, 0).Activate[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] 'Add the Subtotals (Red Font and BOLDED)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] x = ActiveCell.Offset(1, 2).End(xlUp).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] y = ActiveCell.Offset(-Appy, 2).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2) = "=SUBTOTAL(9," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveWorkbook.Names.Add Name:="Applied", RefersToR1C1:=ActiveCell.Offset(0, 2)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2) = "=SUBTOTAL(3," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End If[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]'This will prevent an error if there are no Unapplied Receipts[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]If UnAp <> 0 Then[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC2 = Cells.Find("Unapplied", After:=ActiveCell, SearchDirection:=xlNext).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC2 = Range(MCC2).Offset(UnAp, 0).Activate[/COLOR][/FONT]
[COLOR=black][FONT=Verdana] 'Add the Subtotals (Red Font and BOLDED)[/FONT][/COLOR]
[FONT=Verdana][COLOR=black] x = ActiveCell.Offset(1, 2).End(xlUp).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] y = ActiveCell.Offset(-UnAp, 2).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2) = "=SUBTOTAL(9," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveWorkbook.Names.Add Name:="Unapplied", RefersToR1C1:=ActiveCell.Offset(0, 2)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2) = "=SUBTOTAL(3," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End If[/COLOR][/FONT]
[COLOR=black][FONT=Verdana]'This will prevent an error if there are no Unidentified Receipts[/FONT][/COLOR]
[FONT=Verdana][COLOR=black]If Unid <> 0 Then[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC3 = Cells.Find("Unidentified", After:=ActiveCell, SearchDirection:=xlNext).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]MCC3 = Range(MCC3).Offset(Unid, 0).Activate[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] 'Add the Subtotals (Red Font and BOLDED)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] x = ActiveCell.Offset(1, 2).End(xlUp).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] y = ActiveCell.Offset(-Unid, 2).Address(False, False)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2) = "=SUBTOTAL(9," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, 2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveWorkbook.Names.Add Name:="Unidentified", RefersToR1C1:=ActiveCell.Offset(0, 2)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2) = "=SUBTOTAL(3," & x & ":" & y & ")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(0, -2).Font.Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End If[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]'Find the Totals row[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Cells.Find(What:="Total for Batch", After:=ActiveCell, LookIn:=xlFormulas _[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] MatchCase:=False, SearchFormat:=False).Activate[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]'Name the cell Totals[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]ActiveWorkbook.Names.Add Name:="Totals", RefersToR1C1:=ActiveCell.Offset(0, 7)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]'Add formula to ADD up Applied,Unapplied and Unidentified Receipts[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]ActiveCell.Offset(3, 7).FormulaR1C1 = "=IF(Applied+Unapplied+Unidentified-Totals<>0,""Not Balanced"",""Balanced"")"[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]ActiveCell.Offset(3, 7).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Formula1:="=""Not Balanced"""[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] With ActiveCell.Offset(3, 7).FormatConditions(1).Font[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .Italic = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .ColorIndex = 3[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End With[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] ActiveCell.Offset(3, 7).FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, _[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] Formula1:="=""Balanced"""[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] With ActiveCell.Offset(3, 7).FormatConditions(2).Font[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .Bold = True[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .Italic = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .ColorIndex = 43[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End With[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]'Center cell contents[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] With ActiveCell.Offset(3, 7)[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .HorizontalAlignment = xlCenter[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .VerticalAlignment = xlBottom[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .WrapText = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .Orientation = 0[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .AddIndent = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .IndentLevel = 0[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .ShrinkToFit = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .ReadingOrder = xlContext[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] .MergeCells = False[/COLOR][/FONT]
[FONT=Verdana][COLOR=black] End With[/COLOR][/FONT]
[FONT=Verdana][COLOR=black]End Sub<o:p></o:p>[/COLOR][/FONT]
[/COLOR][/FONT]