Thanks for the code. It works when I tested it. One problem that I forgot
to mention. I have two worksheets that I would like to run this code
against.
I have the following routine
Private Sub Workbook_SheetDeactivate(ByVal Sh As Object)
If Sh.Name = "Construction Expenses" Or Sh.Name = "Misc Expenses" Then
Calc_New_Expenses
End If
and I would like to run your code for each sheet. How can I run this code
in the Calc_New_Expenses routine and have it applied to each sheet?
Here is the contents of the routine as it stands now:
Sub Calc_New_Expenses()
Worksheets("Amounts").Range("cash_to_gary").Value = _
WorksheetFunction.SumIf(Range("Paid_By"), "Gary",
Range("Paid_By").Offset(0, -2)) _
+ WorksheetFunction.SumIf(Range("Paid_By_Misc"), "Gary",
Range("Paid_By_Misc").Offset(0, -2)) + _
WorksheetFunction.SumIf(Range("Paid_By"), "Charge",
Range("Paid_By").Offset(0, -2)) _
+ WorksheetFunction.SumIf(Range("Paid_By_Misc"), "Charge",
Range("Paid_By_Misc").Offset(0, -2))
Worksheets("Amounts").Range("cash_to_dom").Value = _
WorksheetFunction.SumIf(Range("Paid_By"), "Dom",
Range("Paid_By").Offset(0, -2)) _
+ WorksheetFunction.SumIf(Range("Paid_By_Misc"), "Dom",
Range("Paid_By_Misc").Offset(0, -2))
Dim rCell As Range
For Each rCell In Range(Cells(1, 5), Cells(Rows.Count, 5).End(xlUp))
With rCell
If IsNumeric(.Value) Then _
If .Value < 0 Then _
.Offset(0, -4).Resize(1, 5).Interior.ColorIndex = 3
End With
Next
Exit Sub
Hope this makes sense.
Thanks,
Gary