Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:54:42+00:00 2026-06-12T18:54:42+00:00

I want fill a drop down list based on user selection in another. Can’t

  • 0

I want fill a drop down list based on user selection in another. Can’t find anything related to it online.

I have a workbook called lookupDept containing the following table:

A   B
==  ==============================
BS  Business School
CG  Chemical Engineering

where column A has the defined name deptCode and column B has the defined name deptName. I have a second workbook called lookupModule which contains the following table:

A       B                                                   C
======  ==================================================  ==
BSA005  Organisational Behaviour                            BS
BSA007  Skills for Study                                    BS
CGA001  Fluid Mechanics I MEng & BEng Status                CG
CGA002  Stagewise Processes                                 CG

I’m trying to update cbo_moduleCode on my form to select a range where column A in lookupDept matches column C in lookupModule. This is the code I’m using:

So if the user picks BS – Business School on the form (which is extracted from the lookupDept workbook, I want all the fields containing BS in column C of the lookupModule workbook to selected. This is the code I’m using so far:

Private Sub UserForm_Initialize()

    Dim c_deptCode As Range
    Dim c_deptName As Range

    Dim deptCodes As Variant
    Dim deptNames As Variant

    Dim ws_dept As Worksheet
    Dim ws_misc As Worksheet
    Set ws_dept = Worksheets("lookupDept")
    Set ws_misc = Worksheets("lookupMisc")

    ' Assign each range to an array containing the values
    deptCodes = Choose(1, ws_dept.Range("deptCode"))
    deptNames = Choose(1, ws_dept.Range("deptName"))

    ' Create deptcode+deptname cbo
    For i = 1 To ws_dept.Range("deptCode").Rows.Count
        CombinedName = deptCodes(i, 1) & " - " & deptNames(i, 1)
        cbo_deptCode.AddItem CombinedName
    Next i

End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:54:44+00:00Added an answer on June 12, 2026 at 6:54 pm

    You can try adding the items on the fly once the first combobox is selected. This code is a sample that might lead you in the right direction:

    Private Sub cbo_deptCode_Change()
    Dim lLoop As Long, rgLoop As range
    
    For lLoop = 1 To Me.cbo_moduleCode.ListCount
    
        Me.cbo_moduleCode.RemoveItem 0
    
    Next lLoop
    
    Sheets("lookupModule").[a1].CurrentRegion.AutoFilter
    Sheets("lookupModule").[a1].CurrentRegion.AutoFilter Field:=3, Criteria1:=Left(Me.cbo_deptCode.Value, 2)
    
    For Each rgLoop In Sheets("lookupModule").[a1].CurrentRegion.Offset(1).SpecialCells(xlCellTypeVisible).Columns(1).Cells
        If Len(rgLoop) > 0 Then
            Me.cbo_moduleCode.AddItem rgLoop & " - " & rgLoop.Offset(, 1)
        End If
    Next rgLoop
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want fill a drop down list based on user selection in another. I'm
I Had Drop down list and I want to fill it with data from
I want to add Drop Down List html control to the web page fill
I had drop down list and I want to fill it with data by
I want fill five years in a drop-down using javascript and the years will
I have two tables: I want to fill an ASP.NET server control drop down
I want to create a form for my user which shows a drop down
Edit Is there any other way I can fill the 2nd drop down as
I want to fetch a selected value from a drop down 'select' list of
I am trying to fill my view model with some drop down options from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.