Live-Forum - Die aktuellen Beiträge
Datum
Titel
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1148to1152
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

code an blatt anpassen

code an blatt anpassen
franz
hallo gemeinde,
habe eine beispielmappe für adresseinträge gefunden, würde gerne die userform
und den code in meiner datei einbinden bzw nachbauen. problem: die daten sollen
in meiner datei in blatt6 eingetragen werden. weiss leider nicht an welcher stelle
und wie der code entsprechend angepasst werden muss. bitte daher um eure hilfe.
gruss
franz
Option Explicit
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)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
End Sub
Private Sub CommandButton1_Click()
If ComboBox1.ListIndex > 0 Then
Rows(ComboBox1.ListIndex + 1).Delete
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
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 = [A65536].End(xlUp).Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Cells(xZeile, 1) = TextBox1
Cells(xZeile, 2) = TextBox2
Cells(xZeile, 3) = TextBox3
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
Columns("A:C").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim aRow, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A65536].End(xlUp).Row
ComboBox1.AddItem "neue Person hinzufügen"
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
Da nix addressiert ist, arbeitet dieser
30.03.2010 15:56:20
Renee
Code mit dem aktiven Tabellenblatt, Franz
Sonst setzt du vor jeden Cells, Columns, Rows, Range oder [Zellreferenz] Ausdruck den Objekt-Identifier Worksheets("blatt6"). (beachte den Punkt, der gehört dazu!).
GreetZ Renée
AW: Da nix addressiert ist, arbeitet dieser
30.03.2010 16:43:22
franz
hallo renee,
klappt noch nicht bekomme eine fehlermeldung
gruss
franz
xZeile = [A65536].End(xlUp)Worksheets("Tabelle6").Row + 1
aRow = [A65536].End(xlUp)Worksheets("Tabelle6").Row

Option Explicit
Private Sub ComboBox1_Click()
If ComboBox1.ListIndex  0 Then
TextBox1 = Worksheets("Tabelle6").Cells(ComboBox1.ListIndex + 1, 1)
TextBox2 = Worksheets("Tabelle6").Cells(ComboBox1.ListIndex + 1, 2)
TextBox3 = Worksheets("Tabelle6").Cells(ComboBox1.ListIndex + 1, 3)
Else
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
End If
End Sub
Private Sub CommandButton1_Click()
If ComboBox1.ListIndex > 0 Then
Worksheets("Tabelle6").Rows(ComboBox1.ListIndex + 1).Delete
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
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 = [A65536].End(xlUp)Worksheets("Tabelle6").Row + 1
Else
xZeile = ComboBox1.ListIndex + 1
End If
Worksheets("Tabelle6").Cells(xZeile, 1) = TextBox1
Worksheets("Tabelle6").Cells(xZeile, 2) = TextBox2
Worksheets("Tabelle6").Cells(xZeile, 3) = TextBox3
TextBox1 = ""
TextBox2 = ""
TextBox3 = ""
Worksheets("Tabelle6").Columns("A:C").Sort Key1:=Range("A2"), Order1:=xlAscending, Header:= _
xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
UserForm_Initialize
End Sub
Private Sub CommandButton3_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim aRow, i As Long
Application.EnableEvents = False
ComboBox1.Clear
aRow = [A65536].End(xlUp)Worksheets("Tabelle6").Row
ComboBox1.AddItem "neue Person hinzufügen"
For i = 2 To aRow
ComboBox1.AddItem Cells(i, 1) & ", " & Cells(i, 2)
Next i
ComboBox1.ListIndex = 0
Application.EnableEvents = True
End Sub

Anzeige
Du hast nicht genau umgesetzt.
30.03.2010 16:49:58
Renee
Hi Franz,
Ich z.B. nicht gesagt, vor Row , sondern Rows
Zudem hab ich gesagt, vor Range und vor z.B. [A65536]
GreetZ Renée
.... und Cells ! (owT)
30.03.2010 16:57:38
Renee

AW: Du hast nicht genau umgesetzt.
30.03.2010 17:13:24
franz
hallo renee,
hmmm, hatte ich jetzt aber so gelesen
Sonst setzt du vor jeden Cells, Columns, Rows, Range oder [Zellreferenz]

und wenn ich jetzt rows ersetze bekomme ich wieder eine fehlermeldung
TextBox1 = Worksheets("Tabelle2").(ComboBox1.ListIndex + 1, 1)

gruss
franz
NICHT ERsetzen, sonder VOR x setzen (owt)
30.03.2010 19:15:42
Renee

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige