VBA Sumif Function

TaskMaster

Board Regular
Joined
Oct 15, 2020
Messages
75
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi all,

I have been trying to integrate some formulas into my VBA but struggling with the following sumif. In the data tab I have a list of dates in column T and the sum range is CB. I am wanting the total of the sumif in C2 of the movements tab where the date is before the current day. Thank you in advance

VBA Code:
Sheets("Movements").Range("C2") = WorksheetFunction.SumIf(Range('Data'!T:T), Range("<Format(Date, "dd/mm/yyyy")"), Range('Data'!CB:CB))
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Not sure if you want a formula or value but try:

Value:
Excel Formula:
Sheets("Movements").Range("C2").Value = WorksheetFunction.SumIf(Sheets("Data").Range("T:T"), Format(Date, "dd/mm/yyyy"), Sheets("Data").Range("CB:CB"))

Formula:
Excel Formula:
Sheets("Movements").Range("C2").Formula = "=SUMIF('Data'!T:T, TEXT(TODAY(), ""dd/mm/yyyy""), 'Data'!CB:CB)"
 
Upvote 0
Solution
Not sure if you want a formula or value but try:

Value:
Excel Formula:
Sheets("Movements").Range("C2").Value = WorksheetFunction.SumIf(Sheets("Data").Range("T:T"), Format(Date, "dd/mm/yyyy"), Sheets("Data").Range("CB:CB"))

Formula:
Excel Formula:
Sheets("Movements").Range("C2").Formula = "=SUMIF('Data'!T:T, TEXT(TODAY(), ""dd/mm/yyyy""), 'Data'!CB:CB)"
This works perfectly, is it possible to alter so it picks up days less than the current day?
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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