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

Hi,

Can I please have some help with the following code.

Range("A4").Select
Selection.AutoFill Destination:=Range("A5", (("NETDAYS"))).Value

NETDAYS is a named range that for demo purposes holds a value of "A20", so
the range to fill is A5:NETDAYS.

But something is wrong that I can't figure out.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Selection autofill

Firstly the AutoFill destination range starts on the same range as the cell
that holds the first value. In this case A4. Following should do the trick.

Range("A4").Select
Selection.AutoFill Destination:=Range("A4:NETDAYS")

However, it is not necessary to actually select. The following code is the
better method.

Range("A4").AutoFill Destination:=Range("A4:NETDAYS")


--
Regards,

OssieMac


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Selection autofill

Thanks for that reply OssieMac,

The named range NETDAYS is not actually at cell A20, but holds the value
A20, so what I need is an indirect reference to whatever value NETDAYS holds,
which could change to say A25 based on a calulation elsewhere.

Sorry if this was not made clear earlier.

"OssieMac" wrote:

Firstly the AutoFill destination range starts on the same range as the cell
that holds the first value. In this case A4. Following should do the trick.

Range("A4").Select
Selection.AutoFill Destination:=Range("A4:NETDAYS")

However, it is not necessary to actually select. The following code is the
better method.

Range("A4").AutoFill Destination:=Range("A4:NETDAYS")


--
Regards,

OssieMac


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Selection autofill

Try the following. Note that a space and underscore at the end of a line is a
line break in an otherwise single line of code.

Using Selection method.

Range("A4").Select
Selection.AutoFill _
Destination:=Range(Selection, _
Range("NETDAYS").Value)


Alternative method.
Range("A4").AutoFill _
Destination:=Range("A4:" & _
Range("NETDAYS").Value)


--
Regards,

OssieMac


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Selection autofill

Another option instead of using the colon and concatenating the range, a
comma can be used between the start and end ranges. (Similar to the Selection
example.)

Range("A4").AutoFill _
Destination:=Range("A4", _
Range("NETDAYS").Value)

--
Regards,

OssieMac




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Selection autofill

Once again thank you for your assitance,

I have tried all combinations of code and keeping getting this error:
Run-time error 1004
Method 'range' of object'_Global failed.

Would you be able to shed some light.

"OssieMac" wrote:

Another option instead of using the colon and concatenating the range, a
comma can be used between the start and end ranges. (Similar to the Selection
example.)

Range("A4").AutoFill _
Destination:=Range("A4", _
Range("NETDAYS").Value)

--
Regards,

OssieMac


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Selection autofill

Hang on wait a minute,

Thank you Ossiemac, eveything is tickty boo.

Cheers

"LaDdIe" wrote:

Once again thank you for your assitance,

I have tried all combinations of code and keeping getting this error:
Run-time error 1004
Method 'range' of object'_Global failed.

Would you be able to shed some light.

"OssieMac" wrote:

Another option instead of using the colon and concatenating the range, a
comma can be used between the start and end ranges. (Similar to the Selection
example.)

Range("A4").AutoFill _
Destination:=Range("A4", _
Range("NETDAYS").Value)

--
Regards,

OssieMac


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
Selection AutoFill, Excel 2000 & 2003 James Cooper Excel Worksheet Functions 1 January 28th 07 07:51 AM
Selection.Autofill Destination:=Range(ActiveCell.Value) [email protected] Excel Programming 6 April 23rd 06 11:15 PM
AutoFill on selection Desert Piranha[_61_] Excel Programming 5 March 5th 06 12:29 AM
Function to store last row and use in autofill selection wayliff Excel Programming 2 December 26th 05 01:27 PM


All times are GMT +1. The time now is 05:06 AM.

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"