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

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
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,215,563
Messages
6,125,565
Members
449,237
Latest member
Chase S

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