+ Reply to Thread
Results 1 to 3 of 3

Userform ComboBox.List Location and Active Sheet Issues

Hybrid View

AlvaroSiza Userform ComboBox.List... 02-24-2013, 08:27 PM
AlphaFrog Re: Userform ComboBox.List... 02-24-2013, 09:08 PM
AlvaroSiza Re: Userform ComboBox.List... 02-24-2013, 09:55 PM
  1. #1
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Userform ComboBox.List Location and Active Sheet Issues

    Attempting to populate Combobox within Userform Initialize event. The cbo is populated from an advanced filter / unique list on a hidden worksheet. The cbo properly populates when that worksheet is the active sheet, but not from the worksheet where the userform (and initialize event) is fired. I thought encapsulating within a With/End With construct would prove the best approach, but to no avail. Thanks.

    With wsData
            '~~> Ensure Dest range is clear prior to firing
            .Range("J1601:J1699").ClearContents
            '~~> Find String, offset 1 x 2, resize range to contiguous end
            Set rngFind = .Range("E:E").Find(strFind, , xlValues, xlWhole).Offset(1, 2)
            Set rngSource = .Range(rngFind, rngFind.End(xlDown))
            '~~> Apply Advanced Filter to send unique names only to range for
            '~~> consumption
            rngSource.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("J1601"), _
                                  Unique:=True
            '~~> Populate combo box with unique list
            Set rngUnique = .Range("J1602", .Range("J1602").End(xlDown))
            Me.cboSubName.List = rngUnique.Value
        End With
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,652

    Re: Userform ComboBox.List Location and Active Sheet Issues

    Missing a period in front of Range("J1601")

            rngSource.AdvancedFilter Action:=xlFilterCopy, CopyToRange:=.Range("J1601"), _
                                  Unique:=True

  3. #3
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: Userform ComboBox.List Location and Active Sheet Issues

    And there you have it.

    <facepalm>

    Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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