Sumproduct calculation vba

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. Windows
How can I use this formula in vba...

=SUMPRODUCT(--(TEXT($D$15:$D$1001,"mmmmyyyy")=$S23&T$14),$P$15:$P$1001)

Thank you kindly
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hello,

When you say ' use ' this formula ...

What is your actual objective :

1. The macro should insert this formula in your worksheet

2. The macro should work out the result of your formula ... and then insert this result in your worksheet

HTH
 
Upvote 0
I want to use vba instead of using a formula
 
Last edited:
Upvote 0
Ok...I've tried really hard to figure out how use "Evaluate" function in conjunction with userform combo boxes, but I fried too many brain cells and feel defeated. I have "cbMon" and "cbYr" combo boxes in a userform that I will used to select the Month & Year. In my original formula: =SUMPRODUCT(--(TEXT($D$15:$D$1001,"mmmmyyyy")=$S23&T$14),$P$15:$P$1001), I want to replace $S23 & T$14 with the "cbMon" & cbYr. My failed attempt to reconcile this problem is below... Can some one assist please.

Thank you kindly

CCI.Caption = Evaluate("SUMPRODUCT(--(TEXT(D15:D1001,""mmmmyyyy"")= & Month & cbYr & ,P15:P1001")
 
Upvote 0
What is the result produced by your formula ... when used in your worksheet ...

You are replacing S23 by CbMon and T14 by CbYr ... are they both comboboxes ... ? ( holding Text ...)
 
Upvote 0
What is the result produced by your formula ... when used in your worksheet ...

You are replacing S23 by CbMon and T14 by CbYr ... are they both comboboxes ... ? ( holding Text ...)

basically, it totals the amounts for all the entries within the month & year selected.
 
Upvote 0
What is the result produced by your formula ... when used in your worksheet ...

You are replacing S23 by CbMon and T14 by CbYr ... are they both comboboxes ... ? ( holding Text ...)

cbMon will have the Months (i.e. January, February, etc.) and cbYr with have 2018, 2019, 2020, etc
 
Upvote 0
Would you mind answering the second question :

You are replacing S23 by CbMon and T14 by CbYr ... are they both comboboxes ... ? ( holding Text ...)
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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