View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick Bernie Deitrick is offline
external usenet poster
 
Posts: 5,441
Default What is the VB code for autofilling relative cells?

StarDust,

To match the column to the left of the activecell:

ActiveCell.AutoFill Destination:=Range(ActiveCell, _
ActiveCell(1, 0).End(xlDown)(1, 2))

HTH,
Bernie
MS Excel MVP


"stardustsparklin" wrote in
message ...
I have recorded a macro, and one of my procedures requires using the
autofill feature. Even thought I selected "relative" values when I began
recording, the auto fill used the absolute values. Now when I run the

macro
on worksheets with more data, it only autofills up until the row I

recorded
the macro with.

In other words, I would like to convert this code:

Selection.AutoFill Destination:=ActiveCell.Range("A1:A5")

to read something like this:

Selection.AutoFill Destination:=ActiveCell.Range("A1:The entire length
the previous column")

Many thanks.