#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copy

Hi All,

Any error with the codes below? The input box is correctly popped up but
nothing or some other text is pasted.

Sub NewCopy()

Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
Range(CopyFrom).Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub


Thanks in advance!

pwz


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy

CopyFrom is already a range. So you don't surround it with range().

copyfrom.copy
activecell.pastespecial ....



pwz wrote:

Hi All,

Any error with the codes below? The input box is correctly popped up but
nothing or some other text is pasted.

Sub NewCopy()

Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
Range(CopyFrom).Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub

Thanks in advance!

pwz


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy

In fact, you may want to allow the user to cancel the selection:

Sub NewCopy()
dim CopyFrom as range

set copyfrom = nothing
on error resume next
Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
on error goto 0

if copyfrom is nothing then
exit sub 'or something else??
end if

CopyFrom.Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub

pwz wrote:

Hi All,

Any error with the codes below? The input box is correctly popped up but
nothing or some other text is pasted.

Sub NewCopy()

Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
Range(CopyFrom).Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub

Thanks in advance!

pwz


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Copy

Dear Dave,

Great thanks to your additional suggestion! The codes work excellently.

"Dave Peterson" wrote in message
...
In fact, you may want to allow the user to cancel the selection:

Sub NewCopy()
dim CopyFrom as range

set copyfrom = nothing
on error resume next
Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
on error goto 0

if copyfrom is nothing then
exit sub 'or something else??
end if

CopyFrom.Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub

pwz wrote:

Hi All,

Any error with the codes below? The input box is correctly popped up but
nothing or some other text is pasted.

Sub NewCopy()

Set CopyFrom = Application.InputBox(prompt:="Copy FROM?", Type:=8)
Range(CopyFrom).Copy
ActiveCell.PasteSpecial Paste:=xlPasteAll, operation:=xlNone

End Sub

Thanks in advance!

pwz


--

Dave Peterson



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
Copy/Paste how to avoid the copy of formula cells w/o calc values Dennis Excel Discussion (Misc queries) 10 March 2nd 06 10:47 PM
copy formulas from a contiguous range to a safe place and copy them back later Lucas Budlong Excel Programming 2 February 22nd 06 08:26 PM
EXCEL FILE a copy/a copy/a copy ....filename ve New Users to Excel 1 September 29th 05 09:12 PM
Code to copy range vs Copy Entire Worksheet - can't figure it out Mike Taylor Excel Programming 1 April 15th 04 08:34 PM
How copy format, font, color and border without copy/paste? Michel[_3_] Excel Programming 1 November 5th 03 04:43 PM


All times are GMT +1. The time now is 02:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"