This function works perfectly to search for a string - if found in a range sum the two values and calculate a percentage contribution to the total
However it takes the Else statement of equal to 1 when I want to enter "0" if the revenue value is equal to zero
I tried the below but it does not replace the 1 with a zero
Any help appreciated
Function Unit(Revenue)
Dim RngX As Range
Dim Reg As String
Dim TtlRevenue As Integer
Reg = Revenue.Offset(0, -5).Value
Set RngX = Worksheets(1).Range("B81:B90").Find(Reg, lookat:=xlPart)
If Not RngX Is Nothing Then
TtlRevenue = Revenue + RngX.Offset(0, 5).Value
Unit = Application.RoundUp(Revenue / TtlRevenue, 1)
Else: Unit = 1
End If
If revenue =0 Then
Unit = 0
End If
End Function
Bookmarks