• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

sum product formula

delta

Member
Range I2: I20 is sum range
Range B2:B20 is Date Range (Contain Different date of months)
TextBox3 is show result of sum for the month
combobox1 contains name of the month

it is use for sum of month select in combobox with the sumproduct function use in userform

>>> use code - tags <<<
Code:
Private Sub CommandButton1_Click()

On Error Resume Next
me.TextBox3.Value = Application.WorksheetFunction.SumProduct(Sheets("Cash_Data").Range("I2:I20"), --(Application.WorksheetFunction.Text(Sheets("Cash_Data").Range("B2:B20"), "MMM") = me.ComboBox1.Value))

End Sub
but when macro is run nothing is show please correct in this code what is wrong
 
Last edited by a moderator:
Range I2: I20 is sum range
Range B2:B20 is Date Range (Contain Different date of months)
TextBox3 is show result of sum for the month
combobox1 contains name of the month

it is use for sum of month select in combobox with the sumproduct function use in userform

>>> use code - tags <<<
Code:
Private Sub CommandButton1_Click()

On Error Resume Next
me.TextBox3.Value = Application.WorksheetFunction.SumProduct(Sheets("Cash_Data").Range("I2:I20"), --(Application.WorksheetFunction.Text(Sheets("Cash_Data").Range("B2:B20"), "MMM") = me.ComboBox1.Value))

End Sub
but when macro is run nothing is show please correct in this code what is wrong
Post your workbook with code, form and sample data. It would be much easier to check and advise for the users here.
 
You cannot compare an array to a value in VBA. You could use Evaluate instead:

Code:
me.TextBox3.Value = Sheets("Cash_Data").Evaluate("SumProduct(I2:I20, --Text(B2:B20, ""MMM"") =" &  me.ComboBox1.Value & ")")
 
Back
Top