Defined name

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Are you using vb or just working within the worksheet?

If vb, then try

debug.print activecell.name.name

Having to use .name property twice threw me for a while.

edit: This only works if the defined name refers to the activecell alone, so isn't going to be much use :(
 
Upvote 0
I’m using VB.
I’m copying a worksheet to a new book. When the new book/sheet is created it copies over a lot of defined names from the original book. I need to replace the defined names in the new book with the values the name refers to but leave several other formulas without defined names unchanged.
 
Upvote 0
Are you looking for code similiar to this?

Code:
Sub ReplaceNamesWithTheirAddress()
  Dim N As Name
  For Each N In Names
    Columns("A").Replace N.Name, N.RefersToRange.Address(0, 0)
  Next
End Sub
 
Upvote 0
That code would cause problems if any of the names were relative, or if short names appeared in longer names, or if the names referred to constants, would it not?
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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