Consulting

Results 1 to 2 of 2

Thread: SUM IFS (Vba)

  1. #1
    VBAX Regular
    Joined
    Dec 2015
    Posts
    40
    Location

    SUM IFS (Vba)

    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.

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    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
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •