Dynamic drop down list, how to do?

aishnad

New Member
Joined
Aug 17, 2011
Messages
2
Sheet 1
ColA ColB
1 AnsA
3 AnsR
1 AnsF
1 AnsS
2 AnsD

Sheet 2 - Should have drop down
ColC - should have unique list from Sheet1!ColA. for eg. 1,3,2
ColD - list should be based on selection in ColC. For eg., if I select 1 in ColC, This should list AnsA, AnsF, AnsS

How to do this?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
If that doesnt work for you....Try below code that gives you a unique list of items from ColA. change accordingly to print in sheet2. now it takes data from colA of activesheet and prints in the activesheet in colmunC.



Code:
Sub uniqueList()
Dim uniqueArray() As Variant
Dim count As Integer
Dim notUnique As Boolean

ReDim uniqueArray(0) As Variant
uniqueArray(0) = Range("A1")
count = 0

Dim cl As Range
For Each cl In Range("A2:A" & Range("A" & Rows.count).End(xlUp).Row)
    notUnique = False
    For i = LBound(uniqueArray) To UBound(uniqueArray)
        If (cl.Value = uniqueArray(i)) Then
            notUnique = True
            Exit For
        End If
    Next i
    
    If notUnique = False Then
        count = count + 1
        ReDim Preserve uniqueArray(count) As Variant
        uniqueArray(UBound(uniqueArray)) = cl.Value
    End If
Next cl

    For i = LBound(uniqueArray) To UBound(uniqueArray)
        Range("C1").Offset(i, 0) = uniqueArray(i)
    Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,818
Messages
6,121,725
Members
449,049
Latest member
MiguekHeka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top