Sumif Vba help

FGaxha

Board Regular
Joined
Jan 10, 2023
Messages
221
Office Version
  1. 365
Platform
  1. Windows
I have vba code to Sumif lookup name.
It is working for one criteria, how to modify for multiple criteria"

Code:
Sub SumDiscountsByOrderDate()
Dim sumRange As Range
Dim criteriaRange As Range
Dim criteria As String

Set sumRange = Range("F2:F11")
Set criteriaRange = Range("B2:B11")
criteria = Range("I4").Value


Range("J4") = WorksheetFunction.SumIfs(sumRange, criteriaRange, criteria)

End Sub
 

Attachments

  • Sumif VBA.png
    Sumif VBA.png
    25.9 KB · Views: 3

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
Why are you using VBA instead of having a SUMIFS formula in column J?

Put this in J4 and then copy down to J10
=SUMIFS($F$2:$F$11, $B$2:$B$11, I4)
 
Upvote 0
I like VBA, because I have a large data source 250k rows. it work easy with vba.
Thank You
 
Upvote 0

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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