should be simple, but formula does not work in VBA

pphilos

New Member
Joined
Oct 21, 2005
Messages
6
Hello


This works as a formula in a cell on the worksheet Sheet1

I want to check 3 criteria

Date in column c on sheet2 is within last 12 months
name matches sheet1 b.58 or Combobox6.value
the letter "S" in column D

=SUMPRODUCT(--(Sheet2!$C$5:$C$3000>$B$1-365),--(Sheet2!$B$5:$B$3000=Sheet1!B58),--(Sheet2!$D$5:$D$3000="S"))

However, I would like to perform the same calculation in VBA and display the result on userform 1, TextBox7.

can anyone convert this, so I can use it in a module?

I have tried enclosing in "" but this does not work.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi
have you tried

userform1.textbox7 = Evaluate("SUMPRODUCT(--(Sheet2!$C$5:$C$3000>$B$1-365),--(Sheet2!$B$5:$B$3000=Sheet1!B58),--(Sheet2!$D$5:$D$3000=""S""))")
 
Upvote 0
good news

I did try the evaluate method, but I must have made a mistake somewhere. Thanks for this. However, I would like to use combobox6.value on userform1 instead of Sheet1!B58 in the sumproduct formula.

can I add it straight in or will I have to Dim Array and all that.

Kind regards

Phil
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,533
Members
448,969
Latest member
mirek8991

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