Excel Macro SumIF

munna

New Member
Joined
May 30, 2011
Messages
1
Dear All ;
I am new to this form, i reached here while searching for the examples of sumif to write code in Excel Macros,

I tried one, can anyone find out whats wrong with it,,

Sub aaa()
'
' aaa Macro
'
cell_no = "I2"
Dim val1 As Long
Range(cell_no).Select
val1 = Application.SumIf(Opening_Bal.Range("b2:b2067"), Physical_Bal.Range("b2"), Opening_Bal.Range("i2:i2067"))
Range("I3").Select
End Sub

when i run the code, it comes to sumif and shows object required,,,

Regards,
Moin
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Code:
    Dim cell_no As Range
    Set cell_no = Range("I2")
    cell_no.Value = Application.SumIf(Sheets("Opening_Bal").Range("b2:b2067"), Sheets("Physical_Bal").Range("b2"), Sheets("Opening_Bal").Range("i2:i2067"))
    Range("I3").Select
 
Upvote 0

Forum statistics

Threads
1,224,585
Messages
6,179,702
Members
452,938
Latest member
babeneker

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