How can I return text on confirmation message box from selecting text from a Combobox linked to adjacent cell in a worksheet using a Userform.
Your question is not clear to me(and I am guessing others as well). Can you please provide more description of your setup and what you want to do with it?
Private Sub UserForm_Initialize
With ComboBox1
.BoundColumn = 2
.ColumnCount = 2
.ColumnWidths ="50pt;0pt"
.List = Range("A1:B20").Value ' A1:B20 houses names (column A) and passwords (column B)
End With
End Sub
Private Sub CommandButton1_Click()
If ComboBox1.ListIndex <> -1 Then
MsgBox Combobox1.Column(0) & "'s password is " & ComboBox1.Value
End If
End Sub
That certainly works...Thanks. The other part of it is ....if a user selects a name and password, that name and password should not be available for the next user. Question is how do I code it?You could populate the combobox with both columns, make the password column the bound column and hide it.
Then the Value property of the combobox will return the password for the name selected.
Code:Private Sub UserForm_Initialize With ComboBox1 .BoundColumn = 2 .ColumnCount = 2 .ColumnWidths ="50pt;0pt" .List = Range("A1:B20").Value ' A1:B20 houses names (column A) and passwords (column B) End With End Sub Private Sub CommandButton1_Click() If ComboBox1.ListIndex <> -1 Then MsgBox Combobox1.Column(0) & "'s password is " & ComboBox1.Value End If End Sub