macro to change data table name reference

zoog25

Active Member
Joined
Nov 21, 2011
Messages
394
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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
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)"
 

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
Or maybe better delete the name:
VBA Code:
    With ActiveWorkbook.Worksheets("Final Map").Names("TBDeveloper")
        .Delete
    End With
 
Solution

zoog25

Active Member
Joined
Nov 21, 2011
Messages
394
Thank you for the advice but if i delete the name, how do i create a new one then.
 

mart37

Well-known Member
Joined
Aug 4, 2017
Messages
1,091
Office Version
  1. 2016
Platform
  1. Windows
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,046
Messages
5,639,758
Members
417,109
Latest member
996

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
Top