Results 1 to 9 of 9

dynamic named range not populating combo box list if range = single cell

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-14-2013
    Location
    Ky
    MS-Off Ver
    Excel 2013
    Posts
    344

    dynamic named range not populating combo box list if range = single cell

    I think my error is more related to my Excel formula, but it's showing up when I run my VBA (and the solution may involve VBA) so I'm posting in this forum.

    I have 2 userforms that I use to enter names, Employee names and Supervisor Names. These get listed on the next available row of my "Admin Sheet", using something like:

    Private Sub btnSupAdd_Click()
      Dim ws2 As Worksheet: Set ws2 = Sheets("Admin Menu")
      Dim emptyRow As Long
      With ws2
        'Determine EmptyRow
        emptyRow = WorksheetFunction.CountA(Range("$E:E")) + 1
        Cells(emptyRow, 5).Value = SupNameTextBox.Value
      End With
      Unload Me
    End Sub
    My add employee name routine is similar, only it goes in column B. Because I have a header row, my named range for my supervisor list is:

    Formula: copy to clipboard
    =OFFSET('Admin Menu'!$E$2,0,0,COUNTA('Administrative Menu'!$E:$E)-1,1)


    The "-1" is to account for row 1, the header row, otherwise a blank value shows up in my named range (it would count the header plus all the values beneath in that column, which because my offset formula starts in $E$2 and not $E$1 and the COUNTA formula counts the entire column, $E:$E). Now, this formula works, and when I open my name manager and click into the "Refers to:" box when the named range ("SupList") is selected, I get the moving selection box around cell E2 thru however names are listed below in adjacent rows in column E. Even if there's just 1 name (in E2) and E3 is blank, the name manger recognizes that one cell as my range. If there are 2 names, one in E2 and another in E3, then it recognizes those 2 but not E4. Perfect.

    Here's the problem: When I try to populate a combo box with this named range, if there is only 1 cell in the range (E2), it does not read the value and does not populate with that single name! However, if there are 2 or more values (E2 and E3, plus how ever many more), it works fine and the entire named range is available. My code for populating is:

    Private Sub UserForm_Initialize()
      Dim ws As Worksheet
      On Error Resume Next
      Set ws = Worksheets("Admin Menu")
      Me.cbo1.List = ws.Range("SupList").Value
      'Etc...
    Similar problem with the employee list. If I change the named range formula to
    Formula: copy to clipboard
    =OFFSET('Admin Menu'!$E$2,0,0,COUNTA('Administrative Menu'!$E:$E),1)
    , the range then counts the blank cell after the last name, and includes that blank when the combo box is populated.

    Sorry I cannot provide a sample (too much sanitizing to do) - but is should be fairly simple to understand, hopefully...

    -HeyInKy
    Last edited by HeyInKy; 10-23-2014 at 05:17 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Dynamic List From Single Column of Named Range Table (Permit Open/Close Bracket)
    By BoardGuy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-18-2014, 09:41 AM
  2. [SOLVED] Populating ComboBox using dynamic named range - Error
    By TC1980 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-16-2014, 05:42 AM
  3. Replies: 7
    Last Post: 01-24-2013, 06:55 PM
  4. Replies: 5
    Last Post: 07-27-2010, 10:58 AM
  5. Replies: 1
    Last Post: 06-16-2009, 09:42 AM

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