Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Copying and Pasting cells within an Add-In

Hello

I am putting together an Excel Add-In for a client. One function of the
add-in needs to perform is to give the client the capability to save values
entered as default.

So I have a sheet within the add-in to store the values entered.

The Userform uses the Spreadsheet control from the Microsoft Office Web
Components. The following line of code works, which copies a range of cells
in the control to the clipboard:

xlsExpectedStarts.ActiveSheet.Range(xlsExpectedSta rts.ActiveSheet.ViewableRange).Copy

I am getting the following error when I try and paste the contents to the
worksheet to store the defaults.

Run-time error '-2147024809 (80070057)':
Invalid Argument.

I have tried to specify the range to copy to within the copy statement as
follows:

ThisWorkbook.Sheets("shtT1_Default").Range("rngEST _T1")

I have also tried to paste the cells after the copy statement as follows:

shtPaste = ThisWorkbook.Sheets("shtT1_Default").Range("rngEST _T1").Select
shtPaste.Paste

I get the same error message.

I have used the copy statement by itself and the used Ctrl-V to paste the
cells into a new sheet. So it works, but I have not found the right way to
specifiy it in code.

Any help would greatly be appreciated.

Thanks in advance
Tom Meschede





  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Copying and Pasting cells within an Add-In

Tom,

Some things to consider...

Is the destination sheet protected?
Is the destination sheet paste range the same size as the copied data or a single cell?
Is the destination sheet hidden? I don't believe you can make a selection
on a hidden sheet.
The easiest way to get data from one range to another is simply:
Range(XYZ).Value = Range(ABC).Value
The paste method uses a "Destination" argument unless you select the
destination range in advance (see above).
Also, take a look at the PasteSpecial method.

Regards,
Jim Cone
San Francisco, CA


"TMesh" wrote in message ...
Hello

I am putting together an Excel Add-In for a client. One function of the
add-in needs to perform is to give the client the capability to save values
entered as default.

So I have a sheet within the add-in to store the values entered.

The Userform uses the Spreadsheet control from the Microsoft Office Web
Components. The following line of code works, which copies a range of cells
in the control to the clipboard:

xlsExpectedStarts.ActiveSheet.Range(xlsExpectedSta rts.ActiveSheet.ViewableRange).Copy

I am getting the following error when I try and paste the contents to the
worksheet to store the defaults.

Run-time error '-2147024809 (80070057)':
Invalid Argument.

I have tried to specify the range to copy to within the copy statement as
follows:

ThisWorkbook.Sheets("shtT1_Default").Range("rngEST _T1")

I have also tried to paste the cells after the copy statement as follows:

shtPaste = ThisWorkbook.Sheets("shtT1_Default").Range("rngEST _T1").Select
shtPaste.Paste

I get the same error message.

I have used the copy statement by itself and the used Ctrl-V to paste the
cells into a new sheet. So it works, but I have not found the right way to
specifiy it in code.

Any help would greatly be appreciated.

Thanks in advance
Tom Meschede



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
Pasting Cells in Excel - Not copying all content colleen Excel Discussion (Misc queries) 1 July 15th 09 08:24 PM
Copying cell contents from many cells and pasting into one cell MDN Excel Discussion (Misc queries) 7 December 10th 07 08:56 PM
Copying and pasting to visible cells only FJ Excel Discussion (Misc queries) 4 November 17th 06 01:01 AM
keeping cells locked and protected when copying and pasting Lynne...... Excel Discussion (Misc queries) 0 June 19th 06 12:11 PM
copying and pasting not adjecent cells nick[_2_] Excel Programming 2 October 29th 03 01:05 PM


All times are GMT +1. The time now is 12:51 PM.

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"