Gruppe
Dialog
Bereich
ComboBox
Thema
TextBox in Abhängigkeit einer ComboBox-Auswahl füllen
Problem
Wie kann ich in einer UserForm eine TextBox aus einem Arbeitsblatt in Abhängigkeit einer in einer ComboBox getroffenen Auswahl füllen?
Lösung
Geben Sie den nachfolgenden Code in das Klassenmodul der UserForm ein.
ClassModule: frmInTextBox
Private Sub cboListe_Change()
txtAuswahl.Text = Cells(cboListe.ListIndex + 1, 2)
End Sub
Private Sub cmdWeiter_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim intCounter As Integer
For intCounter = 1 To 12
cboListe.AddItem Cells(intCounter, 1)
Next intCounter
cboListe.ListIndex = 0
End Sub
StandardModule: basMain
Sub CallForm()
frmInTextBox.Show
End Sub