View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
leung leung is offline
external usenet poster
 
Posts: 119
Default Relative Reference and AutoFill- Macro

Hi Rowan

Your code is really useful. However i have a similar situation but the
starting cell to copy down using autofill might not be H2, might be H3, H5,
H100.

Can I use the actively selected cell to perform the autofill down? let say
it is in the H column?

Thanks you very much!

Leung


"Rowan" wrote:

dim endRow as long
endRow = cells(rows.count,7).end(xlup).row
Range("H2").AutoFill Destination:=Range("H2:H" &endrow)

should give your the required result.

Regards
Rowan


"Andy Roberts" wrote:

I need to copy a formula in a new column for each row. When recording the
macro I am using the autofill function however each time I use this
spreadsheet there will be a different number of rows. I need the autofill to
adapt. The following is part of the script I think needs adjustment I just
don't know how to adjust it. Thanks in advance for any ideas.

Range("H2").Select
Selection.AutoFill Destination:=Range("H2:H423")
Range("H2:H423").Select