Hi
I tried your example and it works but when I put those subprocedures on my
macro I get the words of the variable displayed instead of the numerical
result. Maybe because the Saskour20, Saskour40 and SaskTotal come from other
calculation. I don't enter them.
Below is my macro, and I have undeline the subprocedures that are involved
in this macro that I can't make it work. I hate to bother too much but I
have spent a lot of time trying to figure out what the problem is and I can't
Dim Saskour20per As Long, saskour40per As Long, saskourper As Long
Sub other()
Range("B2").Select
FirstRow = ActiveCell.Row
EndRow = Cells(FirstRow, "B").End(xlDown).Row
Set SumRange = Range(Cells(FirstRow, "B"), Cells(EndRow, "B"))
Set CriteriaRange = Range(Cells(FirstRow, "C"), Cells(EndRow, "C"))
sask20 = Application.SumIf(CriteriaRange, "=20", SumRange)
Sask40 = Application.SumIf(CriteriaRange, "=40", SumRange)
sask53 = InputBox("How many UUUU were sent out to Saskatoon?", "UUUU's
to Saskatoon", "0")
SaskTotal = Application.Sum(sask20 + Sask40 + sask53)
-----------------------------------------------------------------------------
Range("B2").Select
FirstRow = ActiveCell.Row
EndRow = Cells(FirstRow, "B").End(xlDown).Row
Set SumRange = Range(Cells(FirstRow, "B"), Cells(EndRow, "B"))
Set CriteriaRange = Range(Cells(FirstRow, "H"), Cells(EndRow, "H"))
Saskcn20 = Application.SumIf(CriteriaRange, "=20CNF001", SumRange)
Saskcn40 = Application.SumIf(CriteriaRange, "=40CNF001", SumRange)
Saskcp20 = Application.SumIf(CriteriaRange, "=20CPF001", SumRange)
Saskcp40 = Application.SumIf(CriteriaRange, "=40CPF001", SumRange)
saskour20 = (sask20 - Saskcn20 - Saskcp20)
-------------------------------------------------------------------
Saskour40 = (Sask40 - Saskcn40 - Saskcp40)
------------------------------------------------------------------
If sask20 <> 0 Then
Saskour20per = Application.Sum(saskour20 / sask20)
-------------------------------------------------------------------------
End If
saskour40per = (Saskour40 / Sask40)
---------------------------------------------------------
saskourper = (saskour20 + Saskour40 + sask53) / SaskTotal
--------------------------------------------------------------------------------
Range("A1").Select
Selection.Value = "Saskatoon " & sask20 & " - 20's & " & Sask40 & " -
40's & " & sask53 & " - NFFU's"
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
If Saskcn20 = 0 And Saskcn40 = 0 And Saskcp20 = 0 And Saskcp40 = 0 Then
Selection.Value = "100% of the equipment supplied by us"
Else
Selection.Value = "saskour20per " & " of the 20' equipment supplied by
us"
ActiveCell.Offset(1, 0).Select
Selection.Value = "saskour40per " & " of the 40' equipment supplied by
us"
ActiveCell.Offset(1, 0).Select
Selection.Value = "We supplied " & " saskourper " & " of the equipment
sent into Saskatoon"
End If
End Sub