ComboBox Value in WorkSheetFunction SumIfs

Hmerman

Board Regular
Joined
Oct 2, 2016
Messages
102
Hello,
Hope you are well.

Is it possible to use a combobox value in the SumIfs WorkSheetFunction?

As I have the below code that caculates the Net Value of weights in Column E on Sheet11 if the Farm name and Type of Drying method for grapes is in Column A and C. The Farm name and Drying method is got from two ComboBox. But it calculates to zero.

Code:
Dim pResult as Double
Dim nettRang as Range, frmRang as Range, drgRang as Range

With Sheet11[INDENT]Set nettRang = .Range("E:E")
[/INDENT]
        Set frmRang = .Range("A:A")
        Set drgRang = .Range("C:C")
           pResult = Application.WorksheetFunction.SumIfs(nettRang, frmRang, " = "  & cbPlFarms.Value, drgRang, " = " & cbPlDroog.Value)
                
                Sheet3.Range("A15").Value = pResult
    
    End With

Can someone please assist or give advice?

Regards
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Just for clarity.
Code:
cbPlFarms.Value
and
Code:
cbPlDroog.Value
are combobox values.
 
Last edited:
Upvote 0
Update:
I have tried placing the combobox values on the Sheet and using the Range.Value as argument in the WorkSheetFunction Sumifs method and noticed that it still caculates to zero. Therefore there must be something wrong with my SumIfs setup:
Code:
pResult = Application.WorksheetFunction.SumIfs(nettRang, frmRang, " = "  & cbPlFarms.Value, drgRang, _
 " = " & cbPlDroog.Value)

Can someone please tell me if they see anything out of place?

P.S. I have checked with the normal/non VBA SumIfs function to check what the answer should be and
it is 4345 kg not zero. I must use VBA SumIfs as the Farm name variable and Drying method variable change to often along with percentages to place them on the Sheet.

The calculation is done from a Userform.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,898
Messages
6,127,633
Members
449,392
Latest member
Kersh82

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top