Results 1 to 4 of 4

Dynamic Combobox

Threaded View

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    cambridge
    MS-Off Ver
    Excel 2003
    Posts
    12

    Dynamic Combobox

    Hi

    I would greatly appreciate some appreciate some help from the experts in this forum, please help if you can.
    I am trying to make the listing range for a combobox dynamic. The combobox listing ranges change depending on the value of a cell.
    i have 3 listing ranges for one combobox, the ranges are factory1, factory2, factory3, all these ranges are static and i would like to make them dynamic.
    i have attached an example file. below is the code i am using:
    [Sub MAIN()
    Dim PT As Range
    Dim i As Long
    With ActiveSheet
    setNames .Range("a6")
    Set PT = .Range("b1")
    i = 1
    Do Until PT = ""
    If .Range("a1").Value = PT.Value Then
    On Error Resume Next
    .ComboBox1.ListFillRange = ThisWorkbook.Names("factory" & i).RefersToRange.Address
    If Err.Number = 1004 Then
    MsgBox "not defined name: factory" & i
    ElseIf Err.Number <> 0 Then
    MsgBox "unexpected error: " & Err.Description
    End If
    On Error GoTo 0
    End If
    i = i + 1
    Set PT = PT.Offset(0, 1)
    Loop
    End With
    End Sub

    Sub setNames(theTopLeft As Range)
    Dim theName As Name
    Dim nameStr As String
    Dim theRng As Range
    Dim i As Long
    Application.DisplayAlerts = False
    theTopLeft.CurrentRegion.CreateNames Top:=True, Left:=False, _
    Bottom:=False, Right:=False
    Application.DisplayAlerts = True
    For Each theName In ThisWorkbook.Names
    With theName.RefersToRange
    For i = .Cells.Count To 1 Step -1
    If .Cells(i) <> "" Then Exit For
    Next
    End With
    If i <> 0 Then theName.RefersTo = theName.RefersToRange.Resize(i, 1)
    Next
    End Sub][/CODE]
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Combobox source , linked to other combobox value ??(DYNAMIC)
    By stevnb in forum Excel Programming / VBA / Macros
    Replies: 40
    Last Post: 01-25-2013, 05:28 AM
  2. Dynamic Combobox help
    By akira115 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-14-2012, 01:49 PM
  3. Dynamic Combobox
    By Mahe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-10-2010, 10:12 AM
  4. dynamic combobox
    By john_t_h in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-14-2005, 10:05 AM
  5. dynamic combobox
    By soasi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2005, 10:00 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1