ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   run time error 1004 (https://www.excelbanter.com/excel-programming/415741-run-time-error-1004-a.html)

Jake

run time error 1004
 
When running code that copies one named range from a workbook to a named
range in another workbook I get this run time error saying Select Method of
Range Class failed. If i copy the range manually i get the message: "A
formula or sheet you want to move or copy contains the name
'WPCodeDescription', which already exists on the destinatin sheet. Do you
want to use this version of the name?" Here is the code that causes the
error:

Workbooks(WkbPrevious).Worksheets(CStr(Cell)).Rang e("WPCodeDescription").Copy

Workbooks(wkb).Worksheets(CStr(Cell)).Range("WPCod eDescription").PasteSpecial
xlPasteValues

thanks for any help,
Jake

Jim Thomlinson

run time error 1004
 
You don't need to copy and paste. Just make the values equal. Try this
instead...


Workbooks(wkb).Worksheets(CStr(Cell)).Range("WPCod eDescription").Value = _
Workbooks(WkbPrevious).Worksheets(CStr(Cell)).Rang e("WPCodeDescription").Value
--
HTH...

Jim Thomlinson


"Jake" wrote:

When running code that copies one named range from a workbook to a named
range in another workbook I get this run time error saying Select Method of
Range Class failed. If i copy the range manually i get the message: "A
formula or sheet you want to move or copy contains the name
'WPCodeDescription', which already exists on the destinatin sheet. Do you
want to use this version of the name?" Here is the code that causes the
error:

Workbooks(WkbPrevious).Worksheets(CStr(Cell)).Rang e("WPCodeDescription").Copy

Workbooks(wkb).Worksheets(CStr(Cell)).Range("WPCod eDescription").PasteSpecial
xlPasteValues

thanks for any help,
Jake


Jake

run time error 1004
 
That's a help, thanks a million Jim!

"Jim Thomlinson" wrote:

You don't need to copy and paste. Just make the values equal. Try this
instead...


Workbooks(wkb).Worksheets(CStr(Cell)).Range("WPCod eDescription").Value = _
Workbooks(WkbPrevious).Worksheets(CStr(Cell)).Rang e("WPCodeDescription").Value
--
HTH...

Jim Thomlinson


"Jake" wrote:

When running code that copies one named range from a workbook to a named
range in another workbook I get this run time error saying Select Method of
Range Class failed. If i copy the range manually i get the message: "A
formula or sheet you want to move or copy contains the name
'WPCodeDescription', which already exists on the destinatin sheet. Do you
want to use this version of the name?" Here is the code that causes the
error:

Workbooks(WkbPrevious).Worksheets(CStr(Cell)).Rang e("WPCodeDescription").Copy

Workbooks(wkb).Worksheets(CStr(Cell)).Range("WPCod eDescription").PasteSpecial
xlPasteValues

thanks for any help,
Jake



All times are GMT +1. The time now is 10:02 AM.

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