#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default AutoFill

Jacqui,

DestRange = "C2:" & "J" & a
This line sets the variant variable DestRange to "B2:J64" -
this is a string. The Autofill method requires a Range
Object for the destination parameter, so you get an error.

The solution is to add a Range(...) property statement
around the text to turn the text into a range object like
this:
Selection.AutoFill Destination:=Range(DestRange),
Type:=xlFillDefault

Cheers,
Dave.
-----Original Message-----
I have searched this newsgroup and managed to come up

with
the following code to define a dynamic range for the
autofill function

Range("B2:B31").Select

Range(Selection, Selection.End(xlDown)).Select


a = ActiveSheet.Cells(Rows.Count, 10).End(xlUp).Row
DestRange = "C2:" & "J" & a


Selection.AutoFill Destination:=(DestRange),
Type:=xlFillDefault

When I run this I get an error Autofill method of range
class failed.
The actual destination range that is produced is exactly
the same as what I would type in ie.

'Selection.AutoFill Destination:=Range("B2:J64"),
Type:=xlFillDefault

Can anyone explain why this does not work?

Thanks

Jacqui
.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default AutoFill

Cheers, saved my sanity :-)


-----Original Message-----
Jacqui,

DestRange = "C2:" & "J" & a
This line sets the variant variable DestRange

to "B2:J64" -
this is a string. The Autofill method requires a Range
Object for the destination parameter, so you get an error.

The solution is to add a Range(...) property statement
around the text to turn the text into a range object like
this:
Selection.AutoFill Destination:=Range(DestRange),
Type:=xlFillDefault

Cheers,
Dave.
-----Original Message-----
I have searched this newsgroup and managed to come up

with
the following code to define a dynamic range for the
autofill function

Range("B2:B31").Select

Range(Selection, Selection.End(xlDown)).Select


a = ActiveSheet.Cells(Rows.Count, 10).End(xlUp).Row
DestRange = "C2:" & "J" & a


Selection.AutoFill Destination:=(DestRange),
Type:=xlFillDefault

When I run this I get an error Autofill method of range
class failed.
The actual destination range that is produced is exactly
the same as what I would type in ie.

'Selection.AutoFill Destination:=Range("B2:J64"),
Type:=xlFillDefault

Can anyone explain why this does not work?

Thanks

Jacqui
.

.

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
Autofill Mrich Excel Worksheet Functions 2 June 22nd 06 02:13 AM
autofill Jimmy Excel Discussion (Misc queries) 2 May 31st 06 07:35 PM
AutoFill Student Excel Discussion (Misc queries) 2 May 30th 06 01:29 PM
autofill Cdavis Excel Discussion (Misc queries) 4 May 10th 06 10:19 PM
Autofill: Need to autofill one week block, (5) weekday only into cells. dstock Excel Discussion (Misc queries) 1 June 17th 05 08:21 PM


All times are GMT +1. The time now is 11:00 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"