vendredi 17 avril 2015

I am getting an #error value when calling the function on excel sheet, get me out of this trouble

i want to create a Function that will calculate the Total quantity of a product with number "pn001" and minus the sum in another sheet, the answer should be displayed in sheet where the function is called



Function salio() As Long

Dim Sumact As Range
Dim Sumact1 As Range
Dim Remain As Long
Dim RR As Long
Dim R As Long
Set Sumact = Sheets(1).Range("A1")
Set Sumact1 = Sheets("SALES").Range("A1")
Sheets("STOCK-OUT").Select
Sumact = Application.SumIf(Range("C3:C5"), "pn001", Range("E3:E5"))
RR = CLng(Sumact)
Sheets("SALES").Select
Sumact1 = Application.SumIf(Range("D2:D5"), "pn001", Range("F2:F5"))
Remain = CLng(Sumact1)
R = RR - Remain
salio = R
End Function

Aucun commentaire:

Enregistrer un commentaire