Anzeige
Archiv - Navigation
1624to1628
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

VBA Code sehr langsam!

VBA Code sehr langsam!
02.06.2018 14:30:37
Anatol
Hallo in die Runde,
ich habe eine Userform gebaut die verschiedene Werte - Zahlen und Text - in eine Tabelle überträgt. An und für sich läuft alles - nur eben sehr langsam.
Das wäre der Code. Kann man so etwas vereinfachen?
Private Sub CommandButton1_Click()
[F18] = UserForm2.TextBox1.Value
End Sub
Private Sub CommandButton2_Click()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox16.Text = ""
TextBox17.Text = ""
TextBox18.Text = ""
TextBox19.Text = ""
TextBox20.Text = ""
TextBox21.Text = ""
TextBox22.Text = ""
TextBox23.Text = ""
TextBox24.Text = ""
TextBox25.Text = ""
TextBox26.Text = ""
TextBox27.Text = ""
TextBox28.Text = ""
TextBox29.Text = ""
TextBox30.Text = ""
TextBox31.Text = ""
TextBox32.Text = ""
TextBox33.Text = ""
TextBox34.Text = ""
TextBox35.Text = ""
TextBox36.Text = ""
TextBox37.Text = ""
TextBox38.Text = ""
TextBox39.Text = ""
TextBox40.Text = ""
TextBox41.Text = ""
TextBox43.Text = ""
TextBox44.Text = ""
TextBox45.Text = ""
TextBox46.Text = ""
TextBox42.Text = ""
TextBox47.Text = ""
TextBox48.Text = ""
TextBox49.Text = ""
TextBox50.Text = ""
TextBox51.Text = ""
TextBox52.Text = ""
TextBox53.Text = ""
TextBox54.Text = ""
End Sub

Private Sub CommandButton3_Click()
Cells(18, 6).Value = Me.TextBox1
Cells(18, 8).Value = Me.TextBox2
If Trim$(TextBox3.Text) vbNullString Then Cells(18, 3).Value = CDbl(TextBox3.Text)
If Trim$(TextBox4.Text) vbNullString Then Cells(18, 11).Value = CDbl(TextBox4.Text)
If Trim$(TextBox5.Text) vbNullString Then Cells(18, 12).Value = CDbl(TextBox5.Text)
If Trim$(TextBox36.Text) vbNullString Then Cells(18, 10).Value = CDbl(TextBox36.Text)
Cells(19, 6).Value = Me.TextBox6
Cells(19, 8).Value = Me.TextBox7
If Trim$(TextBox8.Text) vbNullString Then Cells(19, 3).Value = CDbl(TextBox8.Text)
If Trim$(TextBox9.Text) vbNullString Then Cells(19, 11).Value = CDbl(TextBox9.Text)
If Trim$(TextBox10.Text) vbNullString Then Cells(19, 12).Value = CDbl(TextBox10.Text)
If Trim$(TextBox39.Text) vbNullString Then Cells(19, 10).Value = CDbl(TextBox39.Text)
Cells(20, 6).Value = Me.TextBox17
Cells(20, 8).Value = Me.TextBox18
If Trim$(TextBox19.Text) vbNullString Then Cells(20, 3).Value = CDbl(TextBox19.Text)
If Trim$(TextBox20.Text) vbNullString Then Cells(20, 11).Value = CDbl(TextBox20.Text)
If Trim$(TextBox16.Text) vbNullString Then Cells(20, 12).Value = CDbl(TextBox16.Text)
If Trim$(TextBox37.Text) vbNullString Then Cells(20, 10).Value = CDbl(TextBox37.Text)
Cells(21, 6).Value = Me.TextBox22
Cells(21, 8).Value = Me.TextBox21
If Trim$(TextBox23.Text) vbNullString Then Cells(21, 3).Value = CDbl(TextBox23.Text)
If Trim$(TextBox24.Text) vbNullString Then Cells(21, 11).Value = CDbl(TextBox24.Text)
If Trim$(TextBox25.Text) vbNullString Then Cells(21, 12).Value = CDbl(TextBox25.Text)
If Trim$(TextBox41.Text) vbNullString Then Cells(21, 10).Value = CDbl(TextBox41.Text)
Cells(22, 6).Value = Me.TextBox27
Cells(22, 8).Value = Me.TextBox28
If Trim$(TextBox29.Text) vbNullString Then Cells(22, 3).Value = CDbl(TextBox29.Text)
If Trim$(TextBox30.Text) vbNullString Then Cells(22, 11).Value = CDbl(TextBox30.Text)
If Trim$(TextBox26.Text) vbNullString Then Cells(22, 12).Value = CDbl(TextBox26.Text)
If Trim$(TextBox38.Text) vbNullString Then Cells(22, 10).Value = CDbl(TextBox38.Text)
Cells(23, 6).Value = Me.TextBox32
Cells(23, 8).Value = Me.TextBox31
If Trim$(TextBox33.Text) vbNullString Then Cells(23, 3).Value = CDbl(TextBox33.Text)
If Trim$(TextBox34.Text) vbNullString Then Cells(23, 11).Value = CDbl(TextBox34.Text)
If Trim$(TextBox35.Text) vbNullString Then Cells(23, 12).Value = CDbl(TextBox35.Text)
If Trim$(TextBox40.Text) vbNullString Then Cells(23, 10).Value = CDbl(TextBox40.Text)
Cells(24, 6).Value = Me.TextBox43
Cells(24, 8).Value = Me.TextBox44
If Trim$(TextBox45.Text) vbNullString Then Cells(24, 3).Value = CDbl(TextBox45.Text)
If Trim$(TextBox46.Text) vbNullString Then Cells(24, 11).Value = CDbl(TextBox46.Text)
If Trim$(TextBox42.Text) vbNullString Then Cells(24, 12).Value = CDbl(TextBox42.Text)
If Trim$(TextBox47.Text) vbNullString Then Cells(24, 10).Value = CDbl(TextBox47.Text)
If Trim$(TextBox49.Text) vbNullString Then Cells(27, 3).Value = CDbl(TextBox49.Text)
If Trim$(TextBox48.Text) vbNullString Then Cells(27, 4).Value = CDbl(TextBox48.Text)
If Trim$(TextBox50.Text) vbNullString Then Cells(27, 5).Value = CDbl(TextBox50.Text)
If Trim$(TextBox51.Text) vbNullString Then Cells(27, 6).Value = CDbl(TextBox51.Text)
If Trim$(TextBox52.Text) vbNullString Then Cells(27, 7).Value = CDbl(TextBox52.Text)
If Trim$(TextBox53.Text) vbNullString Then Cells(27, 8).Value = CDbl(TextBox53.Text)
If Trim$(TextBox54.Text) vbNullString Then Cells(27, 9).Value = CDbl(TextBox54.Text)
End Sub

Private Sub CommandButton4_Click()
Unload Me
End Sub
Private Sub UserForm_Activate()
Me.TextBox1.Value = Cells(18, 6)
Me.TextBox2.Value = Cells(18, 8)
Me.TextBox3.Value = Cells(18, 3)
Me.TextBox4.Value = Cells(18, 11)
Me.TextBox5.Value = Cells(18, 12)
Me.TextBox36.Value = Cells(18, 10)
Me.TextBox6.Value = Cells(19, 6)
Me.TextBox7.Value = Cells(19, 8)
Me.TextBox8.Value = Cells(19, 3)
Me.TextBox9.Value = Cells(19, 11)
Me.TextBox10.Value = Cells(19, 12)
Me.TextBox39.Value = Cells(19, 10)
Me.TextBox17.Value = Cells(20, 6)
Me.TextBox18.Value = Cells(20, 8)
Me.TextBox19.Value = Cells(20, 3)
Me.TextBox20.Value = Cells(20, 11)
Me.TextBox16.Value = Cells(20, 12)
Me.TextBox37.Value = Cells(20, 10)
Me.TextBox22.Value = Cells(21, 6)
Me.TextBox21.Value = Cells(21, 8)
Me.TextBox23.Value = Cells(21, 3)
Me.TextBox24.Value = Cells(21, 11)
Me.TextBox25.Value = Cells(21, 12)
Me.TextBox41.Value = Cells(21, 10)
Me.TextBox27.Value = Cells(22, 6)
Me.TextBox28.Value = Cells(22, 8)
Me.TextBox29.Value = Cells(22, 3)
Me.TextBox30.Value = Cells(22, 11)
Me.TextBox26.Value = Cells(22, 12)
Me.TextBox38.Value = Cells(22, 10)
Me.TextBox32.Value = Cells(23, 6)
Me.TextBox31.Value = Cells(23, 8)
Me.TextBox33.Value = Cells(23, 3)
Me.TextBox34.Value = Cells(23, 11)
Me.TextBox35.Value = Cells(23, 12)
Me.TextBox40.Value = Cells(23, 10)
Me.TextBox43.Value = Cells(24, 6)
Me.TextBox44.Value = Cells(24, 8)
Me.TextBox45.Value = Cells(24, 3)
Me.TextBox46.Value = Cells(24, 11)
Me.TextBox42.Value = Cells(24, 12)
Me.TextBox47.Value = Cells(24, 10)
Me.TextBox49.Value = Cells(27, 3)
Me.TextBox48.Value = Cells(27, 4)
Me.TextBox50.Value = Cells(27, 5)
Me.TextBox51.Value = Cells(27, 6)
Me.TextBox52.Value = Cells(27, 7)
Me.TextBox53.Value = Cells(27, 8)
Me.TextBox54.Value = Cells(27, 9)
End Sub
Vielen Dank im voraus und herzliche Grüße,
Anatol

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: VBA Code sehr langsam!
02.06.2018 15:46:34
Werner
Hallo Anatol,
nur auf die Schnelle, versuch es mal mit ausschalten der Bildschrimaktualisierung, der Eventmakros und der automatischen Berechnung
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
'hier dein Code zum Übertragen der Daten aus
'den TextBoxen in die Tabelle
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
Application.ScreenUpdating = True
End Sub
Gruß Werner
AW: VBA Code sehr langsam!
02.06.2018 15:56:00
Anatol
Hallo Werner,
vielen herzlichen Dank, dass läuft schon sehr viel schneller.
Grüße,
Anatol
Anzeige
Gerne u. Danke für die Rückmeldung. o.w.T.
05.06.2018 05:54:35
Werner

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige