ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autofill question (https://www.excelbanter.com/excel-programming/275678-autofill-question.html)

Eric Dreshfield

Autofill question
 
How do I modify the following statement so that it does
not have a specific range hard-coded ?

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

I need it to be generic in nature so that it will copy the
formula from the active cells to all rows below where
there is a value in the cell to the left.

Thanks !!

Trevor Shuttleworth

Autofill question
 
Eric

try this:

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

Regards

Trevor


"Eric Dreshfield" wrote in message
...
How do I modify the following statement so that it does
not have a specific range hard-coded ?

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

I need it to be generic in nature so that it will copy the
formula from the active cells to all rows below where
there is a value in the cell to the left.

Thanks !!




John Green[_2_]

Autofill question
 
Trevor has supplied the code requested, but you don't really need a macro if this is all you are doing. The same operation can be
performed by selecting the cell to be copied and double clicking the Auto-Fill handle at the bottom right corner of the cell,

--

John Green - Excel MVP
Sydney
Australia


"Eric Dreshfield" wrote in message ...
How do I modify the following statement so that it does
not have a specific range hard-coded ?

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

I need it to be generic in nature so that it will copy the
formula from the active cells to all rows below where
there is a value in the cell to the left.

Thanks !!




Eric Dreshfield

Autofill question
 
Thank you both for your reply....I knew about the double
click, but I am needing the macro to automate a process so
I will give the code that Trevor supplied a try.

Thanks for your help !
-----Original Message-----
Eric

try this:

ActiveCell.AutoFill _
Destination:=Range(ActiveCell, _
ActiveCell.Offset(0, -1).End

(xlDown).Offset(0, 1))

Regards

Trevor


"Eric Dreshfield" wrote in message
...
How do I modify the following statement so that it does
not have a specific range hard-coded ?

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

I need it to be generic in nature so that it will copy

the
formula from the active cells to all rows below where
there is a value in the cell to the left.

Thanks !!



.



All times are GMT +1. The time now is 09:09 PM.

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