Autofill Function

P

PGalla06

This there anyway to write code for the autofill function that allows
you to choose a specific number of cells to fill instead of having to
enter the range of cells?

In other words, instead of writing:

Selection.AutoFill Destination:=Range("H21:K21"),
Type:=xlFillDefault

Is it possible to write something that says autofill the 5 cells below
the cell that has been selected?

Any help is greatly appreciated.

Thanks,

Peter
 
B

bhofsetz

Give this a try Peter.

Sub Autofil()
Dim CurRow As Long
CurRow = Selection.Row
Selection.AutoFill Destination:=Range("H" & CurRow & ":K" & CurRow +
5), Type:=xlFillDefault
End Sub

For this example you will need to have a range from H - K selected and
it will autofill the next 5 cells.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top