Thread: AutoFill Method
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Green[_3_] John Green[_3_] is offline
external usenet poster
 
Posts: 49
Default AutoFill Method

Destination should be a range object, not a string.

srcRng.AutoFill Destination:=Range("$A$1:$C$20")

Also, your Set could be shortened:

Set srcRng = Selection


--

John Green - Excel MVP
Sydney
Australia


"Syed Zeeshan Haider" wrote in message ...
Hello Experts,
I have Excel 97 Pro on Win98SE.

I am trying to use AutoFill Method to fill from A1:C1 to A1:C20 using
following syntax:
'------------------------------------------------------

Dim srcRng As Variant
Set srcRng = Range(Selection.Address)
' here Selection.Address = "$A$1:$C$1"

srcRng.AutoFill Destination:="$A$1:$C$20"

'------------------------------------------------------


I am getting following error message:

============================
Run-time error '1004':

AutoFill method of Range class failed
============================

What's wrong with my code?

Thank you,
--
Syed Zeeshan Haider.
http://szh.20m.com/


-----------------------------------
Allah says to Mankind:
"Then which of the favours of your Lord will ye deny?"