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 |
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 |
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 |
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 |
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 |
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 |
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 |
All times are GMT +1. The time now is 06:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com