These Named Ranges are acting so weird

N1Martian

New Member
Joined
May 24, 2011
Messages
11
I created this simple UDF to convert a dynamic named range to a fixed one.

Code:
Public Function D2F(namedrange As String) As String

    'Application.Volatile

    Dim rng As Range
    Set rng = Range(namedrange)
        
    ActiveWorkbook.Names.Add namedrange & "2", rng
     
    D2F = namedrange & "2"
    
End Function

The weird thing that's happening is when I run

= D2F("namedrange")

in VBA it works 100% perfectly. But when I run the exact same command from a cell, it dies at names.add line without any errors, it just goes blah.

Any help would be great.
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
UDF's (functions used on a worksheet) have the same restrictions as worksheet functions do... they cannot make changes to anything other than the displayed value for the cell they are placed in. Scroll down to the text portion of the following webpage to see a listing of these restrictions...

http://www.ozgrid.com/VBA/Functions.htm
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
Members
452,902
Latest member
Knuddeluff

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