Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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
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
Run-time error '1004': PasteSpecial method of Range class failed Conan Kelly Excel Programming 1 August 7th 08 11:21 PM
PasteSpecial Method of Range Class Failed Error a Different Versio SteveC Excel Programming 10 February 16th 07 03:08 PM
PasteSpecial Method of Range Class Failed Error Brian C Excel Programming 5 March 30th 06 08:01 PM
runtime error 1004 pastespecial method of range class failed dreamz[_29_] Excel Programming 5 February 3rd 06 02:57 PM
Run-time error '1004' PasteSpecial Method of Range Class Failed Kevin G[_2_] Excel Programming 1 February 3rd 04 05:01 AM


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