macro to change data table name reference

zoog25

Active Member
Joined
Nov 21, 2011
Messages
418
Hello all,

Here is my situation, i have an issue where i'm dealing with moving a sheet from one workbook to another. In doing so i have a data table called 'TBDeveloper' that is in both book. The problem is that when the sheet moves from the original book to the new book. It's reference show information for the original book. How do i change the reference in order to remove the information? Here is what i was able to pull with recording my movements:

VBA Code:
    With ActiveWorkbook.Worksheets("Final Map").Names("TBDeveloper")
        .Name = "TBDeveloper"
        .RefersToR1C1 = _
        "=OFFSET(Contact!R3C3,0,0,COUNTA('E:\[Book1.xlsx]Contact'!R3C3:R1048576C3),1)"
        .Comment = ""
    End With

As you can see, how to a change to reference to it takes out the 'E:/[Book1.xlsx]. Thank you for any help you can provide.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Can't you change:
.RefersToR1C1 = _
"=OFFSET(Contact!R3C3,0,0,COUNTA('E:\[Book1.xlsx]Contact'!R3C3:R1048576C3),1)"
to
.RefersToR1C1 = _
"=OFFSET(Contact!R3C3,0,0,COUNTA('Contact'!R3C3:R1048576C3),1)"
 
Upvote 0
Or maybe better delete the name:
VBA Code:
    With ActiveWorkbook.Worksheets("Final Map").Names("TBDeveloper")
        .Delete
    End With
 
Upvote 0
Solution
There are two names TBDeveloper. (Use the Name Manager.)
With ActiveWorkbook.Worksheets("Final Map").Names("TBDeveloper") you delete only the name which refers to workbook BOOK1.XLSX
The old name shall then be used on the sheet FINAL MAPS.
 
Upvote 0

Forum statistics

Threads
1,214,945
Messages
6,122,393
Members
449,081
Latest member
JAMES KECULAH

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