I am new to macro and will like to know how to apply a formula to an entire column and wat is its code.
I want to apply formula to column AR and it goes,
=sumif(I:I,I2,N:N)
the formula has to start from 2nd row coz first ow wld contain a heading.
how shld i apply it.
any help would be appreciated
Thanks in advance
REGARDS,
VIPUL
Last edited by vipul.halbe; 07-04-2011 at 04:19 AM.
Hi Vipul,
Try this:
Regards,Sub Macro1() Dim lngLastRowColI As Long, _ lngLastRowColN As Long lngLastRowColI = ActiveSheet.Cells(Rows.Count, "I").End(xlUp).Row lngLastRowColN = ActiveSheet.Cells(Rows.Count, "N").End(xlUp).Row If lngLastRowColI >= lngLastRowColN Then ActiveSheet.Range("AR2:AR" & lngLastRowColI).Formula = _ "=SUMIF($I$2:$I$" & lngLastRowColI & ",I2,$N$2:$N$" & lngLastRowColI & ")" Else ActiveSheet.Range("AR2:AR" & lngLastRowColN).Formula = _ "=SUMIF($I$2:$I$" & lngLastRowColN & ",I2,$N$2:$N$" & lngLastRowColN & ")" End If End Sub
Robert
____________________________________________
Please ensure you mark your thread as Solved once it is. Click here to see how
If this post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of my post
It works beautifully
Thanks
Regards
Vipul
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks