Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
988to992
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
988to992
988to992
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Code schneller machen
07.07.2008 18:12:00
Heiko
Hallo Leute
ich habe hier diesen Code. Er klappt einwandfrei. Es dauert nur eine zeit bis er die Daten in die vorgegebenen Zellen eingetragen hat. Gibt es eine möglichkeit den Code schneller zu machen?
Gruß Heiko
Hier der Code:

Private Sub CommandButton1_Click()
'Spiel 1
[cm4].Value = TextBox1.Value
[cn4].Value = TextBox2.Value
[co4].Value = TextBox3.Value
[cp4].Value = TextBox4.Value
[cq4].Value = TextBox5.Value
[cr4].Value = TextBox6.Value
'Spiel 2
[cm6].Value = TextBox7.Value
[cn6].Value = TextBox8.Value
[co6].Value = TextBox9.Value
[cp6].Value = TextBox10.Value
[cq6].Value = TextBox11.Value
[cr6].Value = TextBox12.Value
'Spiel 3
[cm8].Value = TextBox13.Value
[cn8].Value = TextBox14.Value
[co8].Value = TextBox15.Value
[cp8].Value = TextBox16.Value
[cq8].Value = TextBox17.Value
[cr8].Value = TextBox18.Value
'Spiel 4
[cm10].Value = TextBox19.Value
[cn10].Value = TextBox20.Value
[co10].Value = TextBox21.Value
[cp10].Value = TextBox22.Value
[cq10].Value = TextBox23.Value
[cr10].Value = TextBox24.Value
'Spiel 5
[cm12].Value = TextBox25.Value
[cn12].Value = TextBox26.Value
[co12].Value = TextBox27.Value
[cp12].Value = TextBox28.Value
[cq12].Value = TextBox29.Value
[cr12].Value = TextBox30.Value
'Spiel 6
[cm14].Value = TextBox31.Value
[cn14].Value = TextBox32.Value
[co14].Value = TextBox33.Value
[cp14].Value = TextBox34.Value
[cq14].Value = TextBox35.Value
[cr14].Value = TextBox36.Value
'Spiel 7
[cm16].Value = TextBox37.Value
[cn16].Value = TextBox38.Value
[co16].Value = TextBox39.Value
[cp16].Value = TextBox40.Value
[cq16].Value = TextBox41.Value
[cr16].Value = TextBox42.Value
'Spiel 8
[cm18].Value = TextBox43.Value
[cn18].Value = TextBox44.Value
[co18].Value = TextBox45.Value
[cp18].Value = TextBox46.Value
[cq18].Value = TextBox47.Value
[cr18].Value = TextBox48.Value
'Spiel 9
[cm20].Value = TextBox49.Value
[cn20].Value = TextBox50.Value
[co20].Value = TextBox51.Value
[cp20].Value = TextBox52.Value
[cq20].Value = TextBox53.Value
[cr20].Value = TextBox54.Value
'Spiel 10
[cm22].Value = TextBox55.Value
[cn22].Value = TextBox56.Value
[co22].Value = TextBox57.Value
[cp22].Value = TextBox58.Value
[cq22].Value = TextBox59.Value
[cr22].Value = TextBox60.Value
'Spiel 11
[cm24].Value = TextBox61.Value
[cn24].Value = TextBox62.Value
[co24].Value = TextBox63.Value
[cp24].Value = TextBox64.Value
[cq24].Value = TextBox65.Value
[cr24].Value = TextBox66.Value
'Spiel 12
[cm26].Value = TextBox67.Value
[cn26].Value = TextBox68.Value
[co26].Value = TextBox69.Value
[cp26].Value = TextBox70.Value
[cq26].Value = TextBox71.Value
[cr26].Value = TextBox72.Value
Range("c6").Select
Unload Me
End Sub


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

Betreff
Datum
Anwender
Anzeige
AW: Code schneller machen
07.07.2008 18:30:16
Reinhard
Hi Heiko,
probiers mal so:

Option Explicit
Private Sub CommandButton1_Click()
Dim Zei As Long, N As Integer
Application.ScreenUpdating = False
For Zei = 4 To 26 Step 2
Cells(Zei, 91) = Me.Shapes("TextBox" & N + 1)
Cells(Zei, 92) = Me.Shapes("TextBox" & N + 2)
Cells(Zei, 93) = Me.Shapes("TextBox" & N + 3)
Cells(Zei, 94) = Me.Shapes("TextBox" & N + 4)
Cells(Zei, 95) = Me.Shapes("TextBox" & N + 5)
Cells(Zei, 96) = Me.Shapes("TextBox" & N + 6)
N = N + 6
Next Zei
Application.ScreenUpdating = True
End Sub

Gruß
Reinhard

Anzeige
AW: Code schneller machen
07.07.2008 18:43:35
Heiko
Hallo Reinhard
der code klappt nicht bekomme eine fehlermeldung. "Fehler beim Kompilieren:Methode oder Datenobjekt nicht gefunden".Und das macht er mir blau an "Shapes"Was kann das sein?
Gruß Heiko

AW: Code schneller machen
07.07.2008 18:50:09
Reinhard
Hi Heiko,
sorry war und ist ungetestet, aber kriegen wir schon hin,
Ändere mal alles ab in der Form:
Cells(Zei, 91) = Me.Controls("TextBox" & N + 1)
Das müßte funktionieren, wenn nicht melde dich nochmal und stlle die Frage auf noch offen, ich muß jetzt weg aber in 2 Stunden kann ich es dann nachbauen und testen, bzw. bis dahin hat sicher schon ein Andrer den Fehler gefunden.
Gruß
Reinhard

Anzeige
Automatische Berechnung oder Ereignissmakro?
07.07.2008 18:50:00
ransi
HAllo Heiko
Ich glaube da bremst die Automatische Berechnung oder ein Ereignissmakro.
Versuchs mal so:
Option Explicit

Dim AppCalc
Dim AppScreen
Dim AppEvents
Dim AppCursor

Private Sub CommandButton1_Click()
On Error GoTo raus
Call More_speed
'Spiel 1
[cm4].Value = TextBox1.Value
[cn4].Value = TextBox2.Value
[co4].Value = TextBox3.Value
[cp4].Value = TextBox4.Value
[cq4].Value = TextBox5.Value
[cr4].Value = TextBox6.Value
'Spiel 2
[cm6].Value = TextBox7.Value
[cn6].Value = TextBox8.Value
[co6].Value = TextBox9.Value
[cp6].Value = TextBox10.Value
[cq6].Value = TextBox11.Value
[cr6].Value = TextBox12.Value
'Spiel 3
[cm8].Value = TextBox13.Value
[cn8].Value = TextBox14.Value
[co8].Value = TextBox15.Value
[cp8].Value = TextBox16.Value
[cq8].Value = TextBox17.Value
[cr8].Value = TextBox18.Value
'Spiel 4
[cm10].Value = TextBox19.Value
[cn10].Value = TextBox20.Value
[co10].Value = TextBox21.Value
[cp10].Value = TextBox22.Value
[cq10].Value = TextBox23.Value
[cr10].Value = TextBox24.Value
'Spiel 5
[cm12].Value = TextBox25.Value
[cn12].Value = TextBox26.Value
[co12].Value = TextBox27.Value
[cp12].Value = TextBox28.Value
[cq12].Value = TextBox29.Value
[cr12].Value = TextBox30.Value
'Spiel 6
[cm14].Value = TextBox31.Value
[cn14].Value = TextBox32.Value
[co14].Value = TextBox33.Value
[cp14].Value = TextBox34.Value
[cq14].Value = TextBox35.Value
[cr14].Value = TextBox36.Value
'Spiel 7
[cm16].Value = TextBox37.Value
[cn16].Value = TextBox38.Value
[co16].Value = TextBox39.Value
[cp16].Value = TextBox40.Value
[cq16].Value = TextBox41.Value
[cr16].Value = TextBox42.Value
'Spiel 8
[cm18].Value = TextBox43.Value
[cn18].Value = TextBox44.Value
[co18].Value = TextBox45.Value
[cp18].Value = TextBox46.Value
[cq18].Value = TextBox47.Value
[cr18].Value = TextBox48.Value
'Spiel 9
[cm20].Value = TextBox49.Value
[cn20].Value = TextBox50.Value
[co20].Value = TextBox51.Value
[cp20].Value = TextBox52.Value
[cq20].Value = TextBox53.Value
[cr20].Value = TextBox54.Value
'Spiel 10
[cm22].Value = TextBox55.Value
[cn22].Value = TextBox56.Value
[co22].Value = TextBox57.Value
[cp22].Value = TextBox58.Value
[cq22].Value = TextBox59.Value
[cr22].Value = TextBox60.Value
'Spiel 11
[cm24].Value = TextBox61.Value
[cn24].Value = TextBox62.Value
[co24].Value = TextBox63.Value
[cp24].Value = TextBox64.Value
[cq24].Value = TextBox65.Value
[cr24].Value = TextBox66.Value
'Spiel 12
[cm26].Value = TextBox67.Value
[cn26].Value = TextBox68.Value
[co26].Value = TextBox69.Value
[cp26].Value = TextBox70.Value
[cq26].Value = TextBox71.Value
[cr26].Value = TextBox72.Value
Range("c6").Select
Unload Me
raus:
Call Meine_Einstellungen
End Sub

Public Sub More_speed()
With Application
    '#######################
    'Einstellungen speichern
    AppCalc = .Calculation
    AppScreen = .ScreenUpdating
    AppEvents = .EnableEvents
    AppCursor = .Cursor
    '#######################
    'Angezogene Bremsen lösen
    .Calculation = xlCalculationManual 'Berechnung auf manuell
    .ScreenUpdating = False 'Bildschirmaktualisierung aus
    .EnableEvents = False 'Ereignismakros abschalten
    .Cursor = xlDefault 'Sanduhr ausschalten
    '#######################
End With
End Sub

Public Sub Meine_Einstellungen()
With Application
    .Calculation = AppCalc
    .ScreenUpdating = AppScreen
    .EnableEvents = AppEvents
    .Cursor = AppCursor
End With
End Sub


ransi

Anzeige
AW: Automatische Berechnung oder Ereignissmakro?
07.07.2008 19:08:56
Heiko
Hallo Reinhard, hallo Ransi
danke für eure holfe. Klappt alles super. Ist jetzt schneller. Danke !!!
Gruß Heiko

OT Cursor auf Standard setzen
07.07.2008 22:14:31
Reinhard
Hallo Ransi,
wirst du nach Anzahl der Codezeilen bezahlt *mißtrauisch schau* :-)
Mit dem "More Speed" ist ja alles nahezu in Ordnung, aber das mit dem Cursor gibt mir zu denken. Wenn man in der Sanduhr den Sand rieseln sehen könnte dann könnte ich mir vorstellen daß da das Abschalten Zeit bringt, aber so, das bringt doch nix!?
Oder weißt du da wieder was was ich nicht weiß ?
Gruß
Reinhard

16 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige