Sumif with VBA

Akbarov

Active Member
Joined
Jun 30, 2018
Messages
347
Office Version
  1. 365
Platform
  1. Windows
Hey Dear community,

i use this formula =SUM(SUMIF(D:D,A2:A10,E:E)) to find markets total income

D:D whole market names , A2 to A10 name of markets which i need to calculate. and E:E is income from markets

But data is very huge and array formula wont work.

Can anyone help me to do it with VBA code?
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
i found this code

Sub Macro1()
'
Set MyRg1 = Range("C5:C314055")
Set MyRg2 = Range("E5:E314055")
Cells(1, "L") = WorksheetFunction.SumIf(MyRg1, "MARKET", MyRg2)
'
End Sub

But instead of "MARKET" i need to use range from sheet2 A2:A35 how can i use that?
 
Upvote 0
How about
Code:
   Cells(1, "L").Value = Evaluate("=SUM(SUMIF(D5:D314055,A2:A35,E5:E314055))")
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,021
Latest member
Mohamed Magdi Tawfiq Emam

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