ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Paste not working from Add-in - Error 1004 (https://www.excelbanter.com/excel-programming/345462-copy-paste-not-working-add-error-1004-a.html)

Trefor

Copy Paste not working from Add-in - Error 1004
 
The below code is in an add-n, when my main workbook had a reference to the
add-in it worked fine. When I removed the reference, and used RUN to call the
macro it failed as per below. Any ideas?

ThisWorkbook.Names("Data_Main").RefersToRange.Copy
Windows(WorkbookMain).Activate
Sheets("Data").Select
Range("b5").Select
ActiveSheet.Paste <--- errors with Error 1004 Paste method of
Worksheet class failed.

--
Trefor

chijanzen

Copy Paste not working from Add-in - Error 1004
 
Trefor:


if supposition Workbooks("WorkbookMain.xls") already opened

Dim rng As Range
Set rng = Workbooks("WorkbookMain.xls").Worksheets("Data").R ange("B5")
ThisWorkbook.Names("Data_Main").RefersToRange.Copy Destination:=rng

--

http://www.vba.com.tw/plog/


"Trefor" wrote:

The below code is in an add-n, when my main workbook had a reference to the
add-in it worked fine. When I removed the reference, and used RUN to call the
macro it failed as per below. Any ideas?

ThisWorkbook.Names("Data_Main").RefersToRange.Copy
Windows(WorkbookMain).Activate
Sheets("Data").Select
Range("b5").Select
ActiveSheet.Paste <--- errors with Error 1004 Paste method of
Worksheet class failed.

--
Trefor


Trefor

Copy Paste not working from Add-in - Error 1004
 
Perfect, easy when you know how, thankyou very much
--
Trefor


"chijanzen" wrote:

Trefor:


if supposition Workbooks("WorkbookMain.xls") already opened

Dim rng As Range
Set rng = Workbooks("WorkbookMain.xls").Worksheets("Data").R ange("B5")
ThisWorkbook.Names("Data_Main").RefersToRange.Copy Destination:=rng

--

http://www.vba.com.tw/plog/


"Trefor" wrote:

The below code is in an add-n, when my main workbook had a reference to the
add-in it worked fine. When I removed the reference, and used RUN to call the
macro it failed as per below. Any ideas?

ThisWorkbook.Names("Data_Main").RefersToRange.Copy
Windows(WorkbookMain).Activate
Sheets("Data").Select
Range("b5").Select
ActiveSheet.Paste <--- errors with Error 1004 Paste method of
Worksheet class failed.

--
Trefor



All times are GMT +1. The time now is 11:24 AM.

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