Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range PasteSpecial error
Why does the following line doesn't work but, when you split it does?
Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Whre DefYear is the name of a cell. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range PasteSpecial error
Copy and PasteSpecial are two separate statements, so they would normally be
on separate lines. To put multiple statements on a single line you must separate them with a colon. Try this: Range("B8").Copy: Range("DefYear").PasteSpecial (xlPasteValues) You can specify the destination as an optional parameter for the Copy command, but when you add .PasteSpecial it becomes a separate statement. Hope this helps, Hutch "Cantru" wrote: Why does the following line doesn't work but, when you split it does? Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Whre DefYear is the name of a cell. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range PasteSpecial error
Beacause you can't pass parameters to an inline destination. In a separate
line you can construct a full paste command with parameters, just like you've discovered. You could invert the logic and use the .Value option to strip the formula: Range("DefYear").Value = Range("B8").Value Does that work for you? -- "Actually, I *am* a rocket scientist." -- JB (www.MadRocketScientist.com) Your feedback is appreciated, click YES if this post helped you. "Cantru" wrote: Why does the following line doesn't work but, when you split it does? Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Whre DefYear is the name of a cell. Thanks |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range PasteSpecial error
Thanks Hutch, it's clear to me how excel works.
"Tom Hutchins" wrote: Copy and PasteSpecial are two separate statements, so they would normally be on separate lines. To put multiple statements on a single line you must separate them with a colon. Try this: Range("B8").Copy: Range("DefYear").PasteSpecial (xlPasteValues) You can specify the destination as an optional parameter for the Copy command, but when you add .PasteSpecial it becomes a separate statement. Hope this helps, Hutch "Cantru" wrote: Why does the following line doesn't work but, when you split it does? Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Whre DefYear is the name of a cell. Thanks |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Range PasteSpecial error
Thanks JB. The .Value option will not work for me in this case. But it opens
my mind for other possibilites. Thanks again. "JBeaucaire" wrote: Beacause you can't pass parameters to an inline destination. In a separate line you can construct a full paste command with parameters, just like you've discovered. You could invert the logic and use the .Value option to strip the formula: Range("DefYear").Value = Range("B8").Value Does that work for you? -- "Actually, I *am* a rocket scientist." -- JB (www.MadRocketScientist.com) Your feedback is appreciated, click YES if this post helped you. "Cantru" wrote: Why does the following line doesn't work but, when you split it does? Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Range("B8").Copy Range("DefYear").PasteSpecial (xlPasteValues) Whre DefYear is the name of a cell. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Run-time error '1004': PasteSpecial method of Range class failed | Excel Programming | |||
PasteSpecial Method of Range Class Failed Error a Different Versio | Excel Programming | |||
PasteSpecial Method of Range Class Failed Error | Excel Programming | |||
runtime error 1004 pastespecial method of range class failed | Excel Programming | |||
Run-time error '1004' PasteSpecial Method of Range Class Failed | Excel Programming |