Neuaufnahme in Tabelle....geht das eleganter?
12.10.2004 20:40:45
Peter
bin mittlerweile ganz froh, dass ich mit VBA wenigstens was anfangen kann, was auch fehlerfrei funktioniert...aber hat von Euch jemand ne Idee.....das Monster wie nachstehend geht doch bestimmt auch etwas eleganter, oder?....Damit schreibe ich Neuaufnahmen in eine Tabelle und prüfe zwischendurch mit "Call DoppelteB" ab. ob die Kundennummer in Spalte 1 bereits vorhanden ist, wenn ja starte ich ne UF mit dem Warnhinweis und schreibe dann die Dublette in eine "Ausweichtabelle", die sich immer wieder leert..
If UserForm2.ComboBox2.Value = "2003 monatlich" Then
Sheets("Bm2003").Activate
Call DoppelteB
For iCounter = 1 To 41
If UserForm2.Controls("TextBox" & iCounter).Value = "" Then
UserForm2.Controls("TextBox" & iCounter).Value = "n.b."
End If
Sheets("Bm2003").Visible = True
Next iCounter
z = Range("A1000").End(xlUp).Row
Cells(z + 1, 1) = UserForm2.TextBox1.Value
Cells(z + 1, 2) = UserForm2.TextBox2.Value
Cells(z + 1, 3) = UserForm2.TextBox3.Value
Cells(z + 1, 4) = UserForm2.TextBox4.Value
Cells(z + 1, 5) = UserForm2.TextBox5.Value
Cells(z + 1, 6) = UserForm2.TextBox6.Value
Cells(z + 1, 7) = UserForm2.TextBox7.Value
Cells(z + 1, 8) = UserForm2.TextBox8.Value
Cells(z + 1, 9) = UserForm2.TextBox9.Value
Cells(z + 1, 10) = UserForm2.TextBox10.Value
Cells(z + 1, 11) = UserForm2.TextBox11.Value
Cells(z + 1, 12) = UserForm2.TextBox12.Value
Cells(z + 1, 13) = UserForm2.TextBox13.Value
Cells(z + 1, 14) = UserForm2.TextBox14.Value
Cells(z + 1, 15) = UserForm2.TextBox15.Value
Cells(z + 1, 16) = UserForm2.TextBox16.Value
Cells(z + 1, 17) = UserForm2.TextBox17.Value
Cells(z + 1, 18) = UserForm2.TextBox18.Value
Cells(z + 1, 19) = UserForm2.TextBox19.Value
Cells(z + 1, 20) = UserForm2.TextBox20.Value
Cells(z + 1, 21) = UserForm2.TextBox21.Value
Cells(z + 1, 22) = UserForm2.TextBox22.Value
Cells(z + 1, 23) = UserForm2.TextBox23.Value
Cells(z + 1, 24) = UserForm2.TextBox24.Value
Cells(z + 1, 25) = UserForm2.TextBox25.Value
Cells(z + 1, 26) = UserForm2.TextBox26.Value
Cells(z + 1, 27) = UserForm2.TextBox27.Value
Cells(z + 1, 28) = UserForm2.TextBox28.Value
Cells(z + 1, 29) = UserForm2.TextBox29.Value
Cells(z + 1, 30) = UserForm2.TextBox30.Value
Cells(z + 1, 31) = UserForm2.TextBox31.Value
Cells(z + 1, 32) = UserForm2.TextBox32.Value
Cells(z + 1, 33) = UserForm2.TextBox33.Value
Cells(z + 1, 34) = UserForm2.TextBox34.Value
Cells(z + 1, 35) = UserForm2.TextBox35.Value
Cells(z + 1, 36) = UserForm2.TextBox36.Value
Cells(z + 1, 37) = UserForm2.TextBox37.Value
Cells(z + 1, 38) = UserForm2.TextBox38.Value
Cells(z + 1, 39) = UserForm2.TextBox39.Value
Cells(z + 1, 40) = UserForm2.TextBox40.Value
Cells(z + 1, 41) = UserForm2.TextBox41.Value
myArr = Sheets("Bm2003").Range("A4:AO1000")
Sheets("Bm2003").Visible = xlVeryHidden
UserForm2.ComboBox1 = ""
UserForm2.ComboBox1.List = myArr
For iCounter = 1 To 41
UserForm2.Controls("TextBox" & iCounter) = ""
Next iCounter
End If
Danke für Eure Mühe
Peter S.