ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofill Function (https://www.excelbanter.com/excel-programming/332657-autofill-function.html)

PGalla06[_9_]

Autofill Function
 

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


--
PGalla06
------------------------------------------------------------------------
PGalla06's Profile: http://www.excelforum.com/member.php...o&userid=24260
View this thread: http://www.excelforum.com/showthread...hreadid=381649


bhofsetz[_84_]

Autofill Function
 

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


--
bhofsetz
------------------------------------------------------------------------
bhofsetz's Profile: http://www.excelforum.com/member.php...o&userid=18807
View this thread: http://www.excelforum.com/showthread...hreadid=381649



All times are GMT +1. The time now is 01:06 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com