Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Selection AutoFill, Excel 2000 & 2003 | Excel Worksheet Functions | |||
Selection.Autofill Destination:=Range(ActiveCell.Value) | Excel Programming | |||
AutoFill on selection | Excel Programming | |||
Function to store last row and use in autofill selection | Excel Programming |