Clever-Excel-Forum

Normale Version: Übernahme aus ComboBox
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
[
Bild bitte so als Datei hochladen: Klick mich!
]

Hallo zusammen,

ich habe da ein Problem im Bereich Auswahl mit dem Eintrag in der Combobox.

Bei Eingabe der ersten Buchstaben füllt sich der Rest mit den bekannten Namen automatisch auf.
Wenn ich dann aber den Vorgeschlagenen Namen auswähle werden die dazugehörigen Daten (Adresse, Telefon usw) nicht in die dafür vorhandenen TextBoxen eingetragen.
Klicke ich einen anderen Eintrag an und dann wieder diesen, geht's . Was muss ich ändern das er direkt mit Mausklick den ergänzten Namen direkt übernimmt.
Wäre schön wenn mir da jemand helfen könnte.


Code:
Option Explicit


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
       MsgBox "Nicht schließen über den (x) Button, Abbrechen benutzen"
       Cancel = True
End If
End Sub
Private Sub ComboBox1_Click()


If ComboBox1.ListIndex <> 0 Then
   TextBox1 = Cells(ComboBox1.ListIndex + 1, 1)
   TextBox2 = Cells(ComboBox1.ListIndex + 1, 2)
   TextBox3 = Cells(ComboBox1.ListIndex + 1, 3)
   TextBox4 = Cells(ComboBox1.ListIndex + 1, 4)
   TextBox5 = Cells(ComboBox1.ListIndex + 1, 5)
   TextBox6 = Cells(ComboBox1.ListIndex + 1, 6)
   TextBox7 = Cells(ComboBox1.ListIndex + 1, 7)
   TextBox8 = Cells(ComboBox1.ListIndex + 1, 8)
Else
   TextBox1 = ""
   TextBox2 = ""
   TextBox3 = ""
   TextBox4 = ""
   TextBox5 = ""
   TextBox6 = ""
   TextBox7 = ""
   TextBox8 = ""
End If
End Sub

Private Sub CommandButton1_Click()
If ComboBox1.ListIndex > 0 Then
   Rows(ComboBox1.ListIndex + 1).Delete
   TextBox1 = ""
   TextBox2 = ""
   TextBox3 = ""
   TextBox4 = ""
   TextBox5 = ""
   TextBox6 = ""
   TextBox7 = ""
   TextBox8 = ""
   UserForm_Initialize
End If
End Sub

Private Sub CommandButton2_Click()
Dim XZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox1.ListIndex = 0 Then
   XZeile = [A10000].End(xlUp).Row + 1
Else
   XZeile = ComboBox1.ListIndex + 1
End If
Cells(XZeile, 1) = TextBox1
Cells(XZeile, 2) = TextBox2
Cells(XZeile, 3) = TextBox3
Cells(XZeile, 4) = TextBox4
Cells(XZeile, 5) = TextBox5
Cells(XZeile, 6) = TextBox6
Cells(XZeile, 7) = TextBox7
Cells(XZeile, 8) = TextBox8
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
TextBox4 = ""
TextBox5 = ""
TextBox6 = ""
TextBox7 = ""
TextBox8 = ""


UserForm_Initialize
End Sub

Private Sub CommandButton3_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()

Label1 = ActiveSheet.[a1].Value
Label2 = ActiveSheet.[b1].Value
Label3 = ActiveSheet.[c1].Value
Label4 = ActiveSheet.[d1].Value
Label5 = ActiveSheet.[e1].Value
Label6 = ActiveSheet.[f1].Value
Label7 = ActiveSheet.[g1].Value
Label8 = ActiveSheet.[h1].Value

Dim aRow, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A10000].End(xlUp).Row
ComboBox1.AddItem ""
For i = 2 To aRow
   ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub
Hallöchen,

hast Du mal geschaut, ob das erste Click-Ereignis durchlaufen wird und wie der Wert des ListIndex dabei ist?
Hallo,

versuche es mal mit dem Change-Ereignis des Kombinationsfeldes.
Hallo,

habe es wie folgt mal im Einzelschritt nachverfolgt:

-Userform wird initialisiert
-Combobox wird gelöscht
-Combobox wird mit Werten geladen
-Combobox1.Listwert = 0
- Werte sind auf =0
-dann wird die Userform angezeigt

Wenn ich jetzt in der Combobox "Glow" eingebe erscheint dort der komplette Name, und ich kann Ihn im Dropdown auswählen, im Code wird aber das Private Sub ComboBox1_Click nicht gestartet. Es wird erst gestartet wenn ich im Dropdown der Combobox einen anderen Namen anklicke.

- Jetzt steht im ListIndex auch ein Wert und die Tesxtboxen werden entsprechend geladen.

Sorry bin kein Profi, aber hoffe es so einigermaßen erklärt zu haben.
Hallo,

meinen Hinweis ziehe ich zurück. Diese Zeile: If ComboBox1.ListIndex <> 0 Then bewirkt, dass die Auswahl des 1. Eintrages nicht berücksichtigt wird.
Hallo Klaus Dieter,
Super das wars  :17:  manchmal sieht mann den Wald vor lauter Bäumen nicht :)

Ich hab hier noch einen Code zum Schutz meiner Tabellen in den ich gerne die Passworteingabe mit **** anzeigen lassen würde. Habt ihr da noch einen Tipp ?
Danke
Code:
Dim objWorksheet As Worksheet
    Dim strPassword As String
    strPassword = InputBox("Passwort eingeben:", "Passwort")
    If StrPtr(strPassword) = 0 Then Exit Sub
    On Error GoTo Abbruch:
    For Each objWorksheet In ThisWorkbook.Worksheets
        With objWorksheet
            .Unprotect Password:=strPassword
            .Protect Password:=strPassword, UserInterfaceOnly:=False
            .Unprotect Password:=strPassword
        End With
    Next objWorksheet
    ThisWorkbook.Unprotect Password:=strPassword
    Exit Sub
Abbruch:
    MsgBox "Falsches Passwort", vbExclamation, "Hinweis"
End Sub
Hallo,

unter den Eigenschaften der TextBoxen gibt es den Parameter PasswordChair, dort gibst du das Sternchen, oder ein anderes beliebiges Zeichen ein.
Hallo Klaus Dieter,

nach der ersten Euphorie stellt sich jetzt ein anderes Problem ein :(
Bei Eingabe in Auswahl von Namen die nicht bekannt sind kommt Laufzeitfehler 1004

[
Bild bitte so als Datei hochladen: Klick mich!
]
Hallo Arni,

Neue Frage = Neues Thema!

Gruß Uwe