Reassigning a named cell reference

m_in_spain

Board Regular
Joined
Sep 28, 2018
Messages
55
Hi,
I have a named cell on sheet Commercial! at F17 called "Warranty". When i finish and run my project that figure is used in various claculations, the updated workbook is saved as a macro free xlsx file.
My enduser may need to change the "warranty" Figure, however my original sheet containing that will be very hidden.
Is there a way using VBA to change the refers to for the name "Warranty" from =Commercial!$F$17 to =TCJ!$G$47
I can't for the life of me think how to phrase this to search in here or indeed even in Google for this answer
Any help, as ever, will be much appreciated
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
1,295
Office Version
  1. 2013
Platform
  1. Windows
Try something like this
VBA Code:
    Dim oWs As Worksheet
    Set oWs = ThisWorkbook    ' << or whatever workbook the named range is in
    oWs.Names("Warranty").RefersTo = "=TCJ!$G$47"
 

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
1,295
Office Version
  1. 2013
Platform
  1. Windows
Don't know what was wrong with me, but the above code makes less sense. With a little luck you would have discovered it yourself, it should have been like this:
VBA Code:
    Dim oWb As Workbook
    Set oWb = ThisWorkbook    ' << or whatever workbook the named range is in
    oWb.Names("Warranty").RefersTo = "=TCJ!$G$47"
 

m_in_spain

Board Regular
Joined
Sep 28, 2018
Messages
55
Don't know what was wrong with me, but the above code makes less sense. With a little luck you would have discovered it yourself, it should have been like this:
VBA Code:
    Dim oWb As Workbook
    Set oWb = ThisWorkbook    ' << or whatever workbook the named range is in
    oWb.Names("Warranty").RefersTo = "=TCJ!$G$47"
Hi, thanks for that, i did try your first suggestion, but it didnt work, I discovered that i can just get excel to cut and paste the cells i need, before it closes!, but i will now try your later suggestion as it is much neater.
Thanks again
 

Watch MrExcel Video

Forum statistics

Threads
1,123,427
Messages
5,601,605
Members
414,462
Latest member
StageRiis

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