Combo box with two columns. (1 Viewer)

raghuprabhu

Registered User.
Local time
Today, 08:00
Joined
Mar 24, 2008
Messages
154
I have two columns in the combo box in my form.
How do I make the data from the second column populate the worksheet?

It is possible in Access, but not in Excel?

Please look at the attached file.

Thanks

Regards
Raghu
 

Attachments

  • ComboBoxes.zip
    21.6 KB · Views: 125

Gasman

Enthusiastic Amateur
Local time
Today, 15:00
Joined
Sep 21, 2011
Messages
14,054
Change the bound column to 2 ?
 

isladogs

MVP / VIP
Local time
Today, 15:00
Joined
Jan 14, 2017
Messages
18,186
This is mainly an Access forum
You might do better posting at e.g. Mr Excel forum instead

Anyway, assuming it's the same as Access, combo box columns are zero based so the 2nd column is Column(1)

Reference this on your user form as Me.MyComboBoxName.Column(1)
 

raghuprabhu

Registered User.
Local time
Today, 08:00
Joined
Mar 24, 2008
Messages
154
Thanks,

Gasman and Ridders. I have come to know that the combo boxes don't the same in Excel.

Have to do two cascading combo boxes

I have learnt to sort it out.

Regards
Raghu
 

Gasman

Enthusiastic Amateur
Local time
Today, 15:00
Joined
Sep 21, 2011
Messages
14,054
Well for the benefit of anyone else who needs to do the same or similar, at least say how you solved it. :confused:

Thanks,

Gasman and Ridders. I have come to know that the combo boxes don't the same in Excel.

Have to do two cascading combo boxes

I have learnt to sort it out.

Regards
Raghu
 

raghuprabhu

Registered User.
Local time
Today, 08:00
Joined
Mar 24, 2008
Messages
154
My apologies!

I found the solution at this site..

http://www.excel-easy.com/vba/examples/dependent-combo-boxes.html

Code:
Private Sub CommandButton1_Click()
Dim RowCount As Long
Dim benefits, total As Single
If Me.txtName.Value = "" Then
MsgBox "Please enter a name", vbExclamation, "Employee Data"
Me.txtName.SetFocus
End If
'Range("A5") = txtName.Text
If Not IsNumeric(Me.txtSalary.Value) Then
MsgBox "The Amount box must contain a number.", vbExclamation, "Employee Data"
Me.txtSalary.SetFocus
End If
'Range("B5") = txtSalary.Value
benefits = txtSalary.Value * 0.5
'Range("C5") = benefits
total = txtSalary.Value + benefits
'Range("D5") = total
RowCount = Worksheets("Sheet2").Range("A4").CurrentRegion.Rows.Count
With Worksheets("Sheet2").Range("A4")
.Offset(RowCount, 0) = Me.txtName.Value
.Offset(RowCount, 1) = Me.ComboBox1.Value
.Offset(RowCount, 2) = Me.ComboBox1.Column(1) '<<<<<<< this is my soloution
.Offset(RowCount, 3) = Me.txtSalary.Value
.Offset(RowCount, 4) = benefits
.Offset(RowCount, 5) = total
End With
End Sub
 
Last edited:

Users who are viewing this thread

Top Bottom