Sum If Column

marvellousmaz

New Member
Joined
Mar 26, 2014
Messages
7
I write quite a bit of vba but I really cant get my head around this one!

I have entered this in Cell L204

=SUMIF(N204:Z204,">0")

Works a treat.

I would like a vba that enters this in All rows this a value in column N

Don't know why but I just cant seem to get my head around it today!

Any help would be appreciated.

Thanks
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Like this?
Code:
Sub MyMacro()


    Dim LastRow As Long


'   Find last row
    LastRow = ActiveCell.SpecialCells(xlLastCell).Row
    
'   Place formula in column AA for all rows
    Range("AA1:AA" & LastRow).FormulaR1C1 = _
        "=IF(LEN(RC[-13])>0,SUMIF(RC[-13]:RC[-1],"">0""),"""")"


End Sub
 
Upvote 0
Thats great thanks.

I have been messing about with if's and loops and stuff for ages! You know when you just cant see a simple solution!

I settled on this in the end.

Sub Addhours()




Dim LastRow As Long


Sheets("sheet1").Select
ActiveSheet.Range("B2000").End(xlUp).Offset(1, 0).Select

LastRow = ActiveCell.Row

Range("L11:L" & LastRow).FormulaR1C1 = _
"=IF(LEN(RC[+2])>0,SUMIF(RC[+2]:RC[+20],"">0""),"""")"



End Sub

Works a treat

Thanks again
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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