Thursday, November 22, 2018

Extract employee id from text in combobox whenever combobox text is changed in a label,VBA Teacher Sourav,Kolkata 08910141720

Private Sub ComboBox1_Change()

If Me.ComboBox1.Text <> "" Then

If Me.OptionButton1 = True Then
Me.Label1 = Left(Me.ComboBox1.Text, Application.WorksheetFunction.Find(" -", Me.ComboBox1.Text) - 1)

'Me.Label1 = Application.WorksheetFunction.Find(" -", Me.ComboBox1.Text)
Else
'Me.Label1 = Right(Me.ComboBox1.Text, Application.WorksheetFunction.Find(" -", Me.ComboBox1.Text) + 1)
Me.Label1 = Right(Me.ComboBox1.Text, Len(Me.ComboBox1.Text) - (Application.WorksheetFunction.Find(" -", Me.ComboBox1.Text) + 2))


End If


Else

Exit Sub

End If

End Sub

No comments:

Post a Comment