Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Pasting Cells in Excel - Not copying all content | Excel Discussion (Misc queries) | |||
Copying cell contents from many cells and pasting into one cell | Excel Discussion (Misc queries) | |||
Copying and pasting to visible cells only | Excel Discussion (Misc queries) | |||
keeping cells locked and protected when copying and pasting | Excel Discussion (Misc queries) | |||
copying and pasting not adjecent cells | Excel Programming |