ExcelBanter

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

AlanW

copy formula
 
I would like to copy the formula of Cell A1 to A2:A10 by using the following
code, but it always shows the "Object required".

Sub copyfor()
With Range("A1").copy
Range("A2:A10").pastespecial = xlformula
End with
End Sub

Could someone show me the right way to do it.

Thanks

Mike H

copy formula
 
Alan,

A good tip in solving issues like this is to record yourself doing it with
the macro recorder. Try this:-

Sub stantial()
Range("A1").Select
Selection.AutoFill Destination:=Range("A1:A10")
End Sub

Mike

"AlanW" wrote:

I would like to copy the formula of Cell A1 to A2:A10 by using the following
code, but it always shows the "Object required".

Sub copyfor()
With Range("A1").copy
Range("A2:A10").pastespecial = xlformula
End with
End Sub

Could someone show me the right way to do it.

Thanks


Trevor Shuttleworth

copy formula
 
Range("A1").Copy
Range("A2:A10").PasteSpecial Paste:=xlPasteFormulas

Regards

Trevor


"AlanW" wrote in message
...
I would like to copy the formula of Cell A1 to A2:A10 by using the
following
code, but it always shows the "Object required".

Sub copyfor()
With Range("A1").copy
Range("A2:A10").pastespecial = xlformula
End with
End Sub

Could someone show me the right way to do it.

Thanks




I.R))

copy formula
 
On 10 ruj, 09:30, AlanW wrote:
I would like to copy the formula of Cell A1 to A2:A10 by using the following
code, but it always shows the "Object required".

Sub copyfor()
With Range("A1").copy
Range("A2:A10").pastespecial = xlformula
End with
End Sub

Could someone show me the right way to do it.

Thanks


Alan,

Range("A2:A10").Formula = Range("A1").Formula

Regards

Iztok



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

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