Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use Names of Named Ranges in ComboBox

Hello, i have about 20 different named ranges in a worksheet. Each named
range highlights a different range of cells.

Is there a way to add the names of these named ranges to a combobox i have
in a userform? I'm trying to use the combox in the form to select just the
name of the named range, not the cells they will highlight. Hope i make
sense. Thanks in advance!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Use Names of Named Ranges in ComboBox


Hello Eric,

Add this macro to the Declarations section of your UserForm. Change the
name of the worksheet from "Sheet2" to which sheet you want the named
ranges from and the name of the ComboBox from "ComboBox1" to what you
are using.

========================================
Sub GetNamedRanges()

Dim NamedRng As Range

Set Wks = Worksheets("Sheet2")

For I = 1 To ThisWorkbook.Names.Count
X = ThisWorkbook.Names(I).RefersTo
On Error Resume Next
Set NamedRng = ThisWorkbook.Names(I).RefersToRange
If Err < 0 Then
Err.Clear
Else
If Wks.Name = NamedRng.Parent.Name Then
ComboBox1.AddItem = NamedRng.Name.Name
End If
End If
Next I

End Sub
========================================

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.thecodecage.com/forumz/member.php?userid=75
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=51219

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Use Names of Named Ranges in ComboBox

Hi

You can only list all named ranges in the workbook you have to test if
the named range is in the desired sheet.

Change Sheet1 to the name of the desired sheet.

For Each n In ActiveWorkbook.Names
If n.RefersTo Like "*Sheet1*" Then
Me.ComboBox1.AddItem n.Name
End If
Next

Regards,
Per

On 16 Jan., 18:24, Eric Zest <Eric
wrote:
Hello, i have about 20 different named ranges in a worksheet. Each named
range highlights a different range of cells.

Is there a way to add the names of these named ranges to a combobox i have
in a userform? *I'm trying to use the combox in the form to select just the
name of the named range, not the cells they will highlight. *Hope i make
sense. *Thanks in advance!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy worksheet with named ranges to new workbook and keep names in Sandy Excel Programming 1 July 11th 08 07:23 PM
Copy worksheet with named ranges to new workbook and keep names Sandy Excel Worksheet Functions 0 July 11th 08 04:37 PM
Names of named ranges in active sheet only Tom Ogilvy Excel Programming 0 December 8th 06 03:45 AM
Names of named ranges in active sheet only Norman Jones Excel Programming 0 December 7th 06 01:45 PM
union of named ranges based only on the names of those ranges sloth Excel Programming 3 October 2nd 06 03:18 AM


All times are GMT +1. The time now is 10:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"