Consulting

Results 1 to 2 of 2

Thread: SUM IF in vba and result in message box

  1. #1

    SUM IF in vba and result in message box

    Hi,
    I have this file with 3 sheets,on clicking enter you will get a userform that has two button which cleanses the data kept on inv sheet.Now the result is given on calcsheet.
    Now I want the following of "Calc" sheet
    1)=SUMIF(inv!AL:AL,"<13",inv!AK:AK)
    2)=SUM(inv!AK:AK)
    And the result of 1 divided by 2 will be shown as a message box at the click of button 3 on user form.
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    tmp1 = Application.SumIf(Worksheets("inv").Range("AL:AL"), "<13", Worksheets("inv").Range("AK:AK"))
    tmp2 = Application.Sum(Worksheets("inv").Range("AK:AK"))
    MsgBox tmp1 / tmp2
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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