Copy Paste using Sheet Code Name

igeron

New Member
Joined
Oct 25, 2010
Messages
11
Dear All,

I am trying to have a simple copy paste code, using the line below while wbc & wbs different workbooks and Sheet1 is the code name of the target worksheet;

Code:
wbc.Sheet1.Range("d4").Value = wbs.Sheet1.Range("d4").Value

This above line is not working, however the one below, which I use the names as "Worksheets("Status")" is working perfectly fine.

Code:
wbc.Worksheets("Status").Range("d4").Value = wbs.Worksheets("Status").Range("d4").Value

Do you know a way to use code names instead of actual names? The worksheet names would be dynamic, so I need code names.

Thanks in advance
Cheers
Igal
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi Igal

The code name is not a property of the workbook, it's a direct reference to the sheet.

If you really need to use sheet codenames in different workbooks you can get their references first and then perform the copy.

For ex., assuming you already have the references to the workbooks, wbc and wbs, try:

Code:
'...
Dim wsc As Worksheet, wss As Worksheet
'...
 
Set wsc = wbc.Worksheets(wbc.VBProject.VBComponents("Sheet1").Properties("Name").Value)
    
Set wss = wbs.Worksheets(wbs.VBProject.VBComponents("Sheet1").Properties("Name").Value)
 
wsc.Range("D4").Value = wsc.Range("D4").Value
 
Upvote 0
Hi PGC,

Thanks for the tip. It seems useful.

Unfortunately, I have like 30 pages to copy, do you know a practical way to do so, or I should adress all of them?
 
Upvote 0
Unfortunately, I have like 30 pages to copy, do you know a practical way to do so, or I should adress all of them?

??

I have no details and so I don't know how you should address the issue.

From what you say it seems a simple loop would do it, but, as I said, I don't have enough information.
 
Upvote 0

Forum statistics

Threads
1,216,225
Messages
6,129,602
Members
449,520
Latest member
TBFrieds

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top