PDA

View Full Version : [SOLVED] SUM IFS (Vba)



ced0802
01-21-2016, 03:00 PM
Hi everyone,

I have this code, which is a simple SUM ifs, but it is not working (no error but get 0 as answer)


Dim mycode As String
mycode = "BULK08"

stock = Application.WorksheetFunction.SumIfs(wkb.Worksheets("Sheet1").Range("B1:B1000"), wkb.Worksheets("Sheet1").Range("J1:J1000"), "BULK08")

wkb.Worksheets("Ced").Cells(30, 3) = stock



I'd like that when it meets the word "BULK08" in wkb.Worksheets("Sheet1") it would add the numbers in column J (same file)
It would put result in wkb.Worksheets("Ced").Cells(30, 3) = stock


Thank you very much in advance for your help.

SamT
01-21-2016, 03:47 PM
Dim Ced As Worksheet
Dim Sht1 As Worksheet
Set Ced = wkb.Worksheets("Ced") 'If wkb is ThisWorkbook, you don't need wkb dot.
Set Sht1 = wkb.Worksheets("Sheet1")

With Sht1
Ced.Cells(30, 3) = Application.WorksheetFunction.SumIfs(.Range("B1:B1000") = "BULK08", .Range("J1:J1000"))
End with