Auto formula copy

  • Thread starter Thread starter LiAD
  • Start date Start date
L

LiAD

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
 
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
 
Seems perfect

Thanks a lot

Per Jessen said:
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
 
Back
Top