ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Clipboard Data Within Macro (https://www.excelbanter.com/excel-programming/282813-clipboard-data-within-macro.html)

Phil

Clipboard Data Within Macro
 
Is there a way to use data a user saved in the clipboard
prior to running my macro. Or, is there a way to prompt
the user to select a range of data to copy to the
clipboard.

I attempted to use the InputBox Method with a Type:=8
setting but I get an error when I attempt to set the
return value to a variable which I declared as being of
type Range, and then try to select that range. The
specific error I get is "Run-Time error '1004'
Method 'Range' of object '_Global' failed.

------------------------
Dim Data_Copy_Range As Range

Set Data_Copy_Range = Application.InputBox(prompt:="Enter
copy range.", Type:=8)

Range(Data_Copy_Range).Select
------------------------

Please Help?
Phil

Steve Yandl[_3_]

Clipboard Data Within Macro
 
Take a look at Chip Pearson's article
http://www.cpearson.com/excel/clipboar.htm

Steve

"Phil" wrote in message
...
Is there a way to use data a user saved in the clipboard
prior to running my macro. Or, is there a way to prompt
the user to select a range of data to copy to the
clipboard.

I attempted to use the InputBox Method with a Type:=8
setting but I get an error when I attempt to set the
return value to a variable which I declared as being of
type Range, and then try to select that range. The
specific error I get is "Run-Time error '1004'
Method 'Range' of object '_Global' failed.

------------------------
Dim Data_Copy_Range As Range

Set Data_Copy_Range = Application.InputBox(prompt:="Enter
copy range.", Type:=8)

Range(Data_Copy_Range).Select
------------------------

Please Help?
Phil




onedaywhen

Clipboard Data Within Macro
 
You object variable Data_Copy_Range points to the chosen range, so the
line of code should be:

Data_Copy_Range.Select

Note Chip Pearson's excellent code to which Steve refers is for
copying text rather than an Excel Range to the clipboard, so isn't
appropriate here.

"Steve Yandl" wrote in message ...
Take a look at Chip Pearson's article
http://www.cpearson.com/excel/clipboar.htm

Steve

"Phil" wrote in message
...
Is there a way to use data a user saved in the clipboard
prior to running my macro. Or, is there a way to prompt
the user to select a range of data to copy to the
clipboard.

I attempted to use the InputBox Method with a Type:=8
setting but I get an error when I attempt to set the
return value to a variable which I declared as being of
type Range, and then try to select that range. The
specific error I get is "Run-Time error '1004'
Method 'Range' of object '_Global' failed.

------------------------
Dim Data_Copy_Range As Range

Set Data_Copy_Range = Application.InputBox(prompt:="Enter
copy range.", Type:=8)

Range(Data_Copy_Range).Select
------------------------

Please Help?
Phil



All times are GMT +1. The time now is 09:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com