Sub growth() ' ' growth Macro ' Columns("S:S").Select Selection.Insert Shift:=xlToRight Range("S21").Select ActiveCell.FormulaR1C1 = "Growth" Range("S23").Select ActiveCell.FormulaR1C1 = "=(RC[-2]-RC[-1])/RC[-2]" Range("S23").Select Selection.NumberFormat = "0.00%" Selection.AutoFill Destination:=Range("S23:S490") Range("S23:S490").Select End Sub
In the above code, the range is set from S23 to S490.But there could be changes in the number of records in the future. how to make it more dynamic, keeping the S23 as constant but S490 to change depending on the records from RC[-2] and RC[-1]. i.e if columns RC[-2] and RC[-1] have 5000 records in future how make the above code dynamic? -- ---------------------------------------------------------------------------------- Some important links for excel users: 1. Follow us on TWITTER for tips tricks and links : http://twitter.com/exceldailytip 2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310 3. Excel tutorials at http://www.excel-macros.blogspot.com 4. Learn VBA Macros at http://www.quickvba.blogspot.com 5. Excel Tips and Tricks at http://exceldailytip.blogspot.com To post to this group, send email to excel-macros@googlegroups.com <><><><><><><><><><><><><><><><><><><><><><> Like our page on facebook , Just follow below link http://www.facebook.com/discussexcel