get the named items in excel workbook

sush026

New Member
Joined
Jul 23, 2007
Messages
5
hi,

how can i get a list of the named items in a excel workbook (I am using excel 2007 Professional Plus). I need to search if a particular named item exists in the workbook and then i have to set the particular cell with "that" named item with a value. Please tell me how can i do this using C#

Thanks,
Sush
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

xld

Banned
Joined
Feb 8, 2003
Messages
5,378
I'll give you it with VBA, you do the translation

Code:
    On Error Resume Next
    Set rng = Range("myName")
    On Error Goto 0
    If Not rng Is Nothing Then
        rng.Value = "myValue"
    End If
 

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
I don't know about C~, but here is a VBA example:

Code:
Sub Test()
    Dim sName As String
    Dim nName As Name
    sName = "TheName"
    On Error Resume Next
    Set nName = ActiveWorkbook.Names(sName)
    If Err = 0 Then
        Evaluate(nName.RefersTo).Parent.Range(sName).Value = 123
    Else
        Err.Clear
    End If
    On Error GoTo 0
End Sub
 

Forum statistics

Threads
1,181,056
Messages
5,927,864
Members
436,573
Latest member
CMR237

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