Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default AutoFill Method

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?"


  #2   Report Post  
Posted to microsoft.public.excel.programming
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?"




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default AutoFill Method

"John Green" wrote in message ...
Destination should be a range object, not a string.

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


Oh yes! It worked!

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


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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run-time error '1004': AutoFill method of Range class failed murkaboris Excel Discussion (Misc queries) 10 April 16th 09 09:06 PM
Run-time error '1004': AutoFill method of Range class failed murkaboris Excel Discussion (Misc queries) 3 April 14th 09 10:35 PM
Autofill method of range class failed Don Guillett Excel Discussion (Misc queries) 0 February 27th 08 03:56 PM
Autofill method of range class failed Appache Excel Discussion (Misc queries) 5 February 27th 08 03:37 PM
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"