ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Auto formula copy (https://www.excelbanter.com/excel-programming/432958-auto-formula-copy.html)

LiAD

Auto formula copy
 
Hi,

The following code will copy formulas from preset cells down to a certain
row (in this case 500).

How can I change this code to get it to auto fill to where the last line I
need is, based on a set condition, say that cell d of the same row is not=""?

Range("V3:AA3").Select
Selection.AutoFill Destination:=Range("V3:AA500"), Type:=xlFillDefault
Range("V3:AA500").Select

At the moment this part of a sub driven through a form button. Each sheet
this applies do does not have the same cell ranges to copy so the cells to
copy from and to are specified per sheet. Is it possible this can be put in
as a workbook code and run automatically in all the sheets in the workbook?

Thanks

Per Jessen

Auto formula copy
 
Hi

Look at this:

LastRow = Range("D" & Rows.Count).End(xlUp).Row
Range("V3:AA3").AutoFill _
Destination:=Range("V3:AA" & LastRow), Type:=xlFillDefault

As you want to copy from different cells in each sheet, I would have one
macro for each sheet. You don't say under which conditions you want to run
the macro, so I can not give you an answer on this one, but it can be
automated for each sheet.

Hopes this helps.
.....
Per

"LiAD" skrev i meddelelsen
...
Hi,

The following code will copy formulas from preset cells down to a certain
row (in this case 500).

How can I change this code to get it to auto fill to where the last line I
need is, based on a set condition, say that cell d of the same row is
not=""?

Range("V3:AA3").Select
Selection.AutoFill Destination:=Range("V3:AA500"), Type:=xlFillDefault
Range("V3:AA500").Select

At the moment this part of a sub driven through a form button. Each
sheet
this applies do does not have the same cell ranges to copy so the cells to
copy from and to are specified per sheet. Is it possible this can be put
in
as a workbook code and run automatically in all the sheets in the
workbook?

Thanks



LiAD

Auto formula copy
 
Seems perfect

Thanks a lot

"Per Jessen" wrote:

Hi

Look at this:

LastRow = Range("D" & Rows.Count).End(xlUp).Row
Range("V3:AA3").AutoFill _
Destination:=Range("V3:AA" & LastRow), Type:=xlFillDefault

As you want to copy from different cells in each sheet, I would have one
macro for each sheet. You don't say under which conditions you want to run
the macro, so I can not give you an answer on this one, but it can be
automated for each sheet.

Hopes this helps.
.....
Per

"LiAD" skrev i meddelelsen
...
Hi,

The following code will copy formulas from preset cells down to a certain
row (in this case 500).

How can I change this code to get it to auto fill to where the last line I
need is, based on a set condition, say that cell d of the same row is
not=""?

Range("V3:AA3").Select
Selection.AutoFill Destination:=Range("V3:AA500"), Type:=xlFillDefault
Range("V3:AA500").Select

At the moment this part of a sub driven through a form button. Each
sheet
this applies do does not have the same cell ranges to copy so the cells to
copy from and to are specified per sheet. Is it possible this can be put
in
as a workbook code and run automatically in all the sheets in the
workbook?

Thanks





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

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