View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Juan Correa Juan Correa is offline
external usenet poster
 
Posts: 29
Default Question about formulas and ranges.

Hello,

I have the following piece of code (taken from having recorded the
particular steps into a macro).

Sub Macro2()
'
' Macro2 Macro
' Macro recorded 1/28/2009 by Juan S. Correa
'

'
Range("AD2").Select
ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-18],REGION,2,FALSE)"
Range("AD2").Select
Selection.AutoFill Destination:=Range("AD2:AD4513")

End Sub

The code will add the VLOOKUP formula in cell AD2 of my spreadsheet and then
will copy/paste that formula down all the way down to AD4513. That would be
OK if the amount of data comming into the spreadsheet were constant, but some
it varies every month so defining the range as ("AD2:AD4513") is not
practical in my particular case.

What I'm looking for is a way for Excel to copy/paste the formula all the
way down to the last populated row regardless of how many rows of data there
are on the spreadsheet.

Thanks in advance,
Juan Correa