Creating a 2-column drop down combo box in a cell

Marzy

New Member
Joined
Sep 12, 2018
Messages
1
How is a 2-column drop down list created whereby one double clicks in a cell opening the 2-column drop down list then populating the cell with the data from column 2?

The first column is the department name, the second column is the dept numbers, by choosing the dept name the cell is populated with the dept number.
This function is repeated over each row.
Would using a VBA make this function possible?

Thank you.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
May be you can try the following to see if it works for you.

Code:
Private Sub ComboBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
ActiveCell.Value = ComboBox1.Column(0, ComboBox1.ListIndex)
ActiveCell.Offset(0, 1).Value = ComboBox1.Column(1, ComboBox1.ListIndex)
End Sub

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'the combo follows your selection in column 1
If Not Intersect(Target, Columns(1)) Is Nothing Then
'if one cell selected
If Target.Count = 1 Then
With ComboBox1
.Left = Target.Left
.Top = Target.Top
.Width = Target.Width
.Height = Target.Height
End With
End If
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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