Erving
New Member
- Joined
- Mar 10, 2020
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
- Web
Hi everyone!
Question from a rookie.
I am trying to build a userform wich includes 3 comboboxes. The comboboxes refers to a spredsheet list and 3 columns. So RowSourse = Lists!A2:A10 (Lists is the name of the spredsheet) Also have Lists!B2:B10 and C2:C10.
A2:A10 refers to numbers 1 to 9.
B2:B10 refers to letters a to i.
C2:C10 is a mix of both numbers and letters.
I'd like the chosen value (number or letter) in a combobox to end up in a spredsheet named Front.
I don´t have a problem doing this with numbers. Works perfect.
But letters don't end up in the spredsheet. It's like the combobox can't hold text.
I have tried to use "text" instead of "value" in the code but it does not work.
I run this userform via a macro:
Sub test()
UserForm1.Show
End Sub
UserForm code:
Private Sub CommandButton1_Click()
Dim Numbers As Integer
Dim Letters As String
Dim Mix As Variant
If ComboBox1 = True Then
Numbers = ComboBox1.Value
Else: ComboBox1 = False
Numbers = "?"
End If
If ComboBox2 = True Then
Letters = ComboBox2.Value
Else: ComboBox2 = False
Letters = "?"
End If
If ComboBox3 = True Then
Mix = ComboBox3.Value
Else: ComboBox3 = False
Mix = "?"
End If
Sheets("Front").Range("B2").Value = Numbers
Sheets("Front").Range("C2").Value = Letters
Sheets("Front").Range("D2").Value = Mix
Sheets("Front").Range("F2").Value = Numbers & " / " & Letters & " / " & Mix
Unload UserForm1
Question from a rookie.
I am trying to build a userform wich includes 3 comboboxes. The comboboxes refers to a spredsheet list and 3 columns. So RowSourse = Lists!A2:A10 (Lists is the name of the spredsheet) Also have Lists!B2:B10 and C2:C10.
A2:A10 refers to numbers 1 to 9.
B2:B10 refers to letters a to i.
C2:C10 is a mix of both numbers and letters.
I'd like the chosen value (number or letter) in a combobox to end up in a spredsheet named Front.
I don´t have a problem doing this with numbers. Works perfect.
But letters don't end up in the spredsheet. It's like the combobox can't hold text.
I have tried to use "text" instead of "value" in the code but it does not work.
I run this userform via a macro:
Sub test()
UserForm1.Show
End Sub
UserForm code:
Private Sub CommandButton1_Click()
Dim Numbers As Integer
Dim Letters As String
Dim Mix As Variant
If ComboBox1 = True Then
Numbers = ComboBox1.Value
Else: ComboBox1 = False
Numbers = "?"
End If
If ComboBox2 = True Then
Letters = ComboBox2.Value
Else: ComboBox2 = False
Letters = "?"
End If
If ComboBox3 = True Then
Mix = ComboBox3.Value
Else: ComboBox3 = False
Mix = "?"
End If
Sheets("Front").Range("B2").Value = Numbers
Sheets("Front").Range("C2").Value = Letters
Sheets("Front").Range("D2").Value = Mix
Sheets("Front").Range("F2").Value = Numbers & " / " & Letters & " / " & Mix
Unload UserForm1