Sum if with and if function inside it macro excel

tuytuy

Board Regular
Joined
Mar 28, 2013
Messages
75
Hi,
i was trying to write a code that would sum if the cost of data consumption of non blackberry smartphone in national.
so i have a table where i get if the phone is a blackberry or not (column K) and if it is national or international (column N). Here is what i wrote but i get a compile error
Code:
'copy COST OF NON BLACKBERRY DATA NATIONAL
TotalIN = 0
ActiveWorkbook.Sheets("Section_14").Activate
Dim sumnbbItem As Variant
Tete = Array("Mobile Internet", _
                  "Internet On GSM")
For Each cstnbbItem In Tete
  costnbbmn = costnbbmn + WorksheetFunction.SumIf(Range("K$3:K$1048576"), sumnbbItem , _
  (If Range("N$3:N$1048576") = "GPRS national" Then), Range("J$3:J$1048576"))
Next
ActiveWorkbook.Sheets("SynthesisVSD").Activate
Range("A29").Value = "Cost of Non BlackBerry handset National data consumption:"
Range("B29").Value = sumbbmn
End If
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Code:
'copy COST OF NON BLACKBERRY DATA NATIONAL


TotalIN = 0
ActiveWorkbook.Sheets("Section_14").Activate
Dim sumnbbItem As Variant
Tete = Array("Mobile Internet", _
                  "Internet On GSM")
For Each cstnbbItem In Tete
  costnbbmn = costnbbmn + WorksheetFunction.SumIf(Range("K$3:K$1048576"), sumnbbItem, WorksheetFunction.If(Range("N$3:N$1048576"), "GPRS national"), Range("J$3:J$1048576"))
Next
ActiveWorkbook.Sheets("SynthesisVSD").Activate
Range("A29").Value = "Cost of Non BlackBerry handset National data consumption:"
Range("B29").Value = sumbbmn
End If

i've changed my code to the above and know i get a error saying wrong number of argument.
 
Upvote 0

Forum statistics

Threads
1,214,927
Messages
6,122,309
Members
449,080
Latest member
jmsotelo

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