Hallo Holger,
mit "ActiveWorkbook.Worksheets(3).Select" funktioniert es so wie ich es haben wollte.
Herzlichen Dank!
Gruß,,
Wilhelm
Holger schrieb am 12.08.2009 18:41:00:
Hallo Dieminger Wilhelm,
ich habe deinen Code nur kurz geprüft und weiß nicht, ob ich dein Problem richtig erfasst habe. Ich sehe nur in der Private Sub ComboBox2_Click() die Aktivierung der Tabelle3. Ich gehe davon aus, dass du diesen nicht erst drücken willst, bevor die Daten aus Tabelle 3 eingelesen werden sollen. Willst du Daten aus Tabelle3 beim Initialisieren der UserForm laden, solltest du, wenn dieses Tabellenblatt nicht ohne aktiviert ist, in der Private Sub UserForm_Initialize() eine Zeile mit ActiveWorkbook.Worksheets(3).Select oder .activate unterbringen oder die Zellen mit Sheets(3).Calls... ansprechen.
Gruß
Holger
Dieminger Wilhelm schrieb am 12.08.2009 14:54:25:
Hallo, wer kann mir bei folgendem Problem Helfen:
Ich habe eine Excel-Arbeitsmappe mit mehreren Tabellen. Beim Öffnen der Arbeitsmappe werden 2 CommandButton gestartet. Mit dem zweiten CommandButton möchte ich - sowie wie auch beim ersten - ein UserForm öffnen (funktioniert auch) und in dem Userform die Daten aus der Tabelle3 einlesen (fuktioniert nicht). Der vorhandene Code sieht wie folgt aus:
Option Explicit
Private Sub ComboBox2_Click()
ActiveWorkbook.Worksheets(3).Select
If ComboBox2.ListIndex <> 0 Then
TextBox11 = Cells(ComboBox2.ListIndex + 1, 1)
TextBox12 = Cells(ComboBox2.ListIndex + 1, 2)
TextBox13 = Cells(ComboBox2.ListIndex + 1, 3)
TextBox14 = Cells(ComboBox2.ListIndex + 1, 4)
Else
TextBox11 = ""
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
End If
End Sub
Private Sub CommandButton4_Click()
If ComboBox2.ListIndex > 0 Then
Rows(ComboBox2.ListIndex + 1).Delete
TextBox11 = ""
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
UserForm2_Initialize
End If
End Sub
Private Sub CommandButton5_Click()
Dim xZeile As Long
If TextBox1 = "" Then Exit Sub
If ComboBox2.ListIndex = 0 Then
xZeile = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox2.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox11
Cells(xZeile, 2) = TextBox12
Cells(xZeile, 3) = TextBox13
Cells(xZeile, 4) = TextBox14
TextBox11 = ""
TextBox12 = ""
TextBox13 = ""
TextBox14 = ""
Columns("A:C").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Private Sub CommandButton6_Click()
Unload Me
End Sub
Private Sub Label6_Click()
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub UserForm_Initialize()
Dim aRow, i As Long
Application.EnableEvents = False
ComboBox2.Clear
aRow = [A65536].End(xlUp).Row
ComboBox2.AddItem "neue Person hinzufügen"
For i = 2 To aRow
ComboBox2.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox2.ListIndex = 0
Application.EnableEvents = True
End Sub
Danke für jegliche Hilfe!
Gruß,
Wilhelm |