ich wende mich an das Forum mit folgendem Problem:
Ich habe ein VBA Script was einfache Berechnungen mit Bezügen, da dynamischer Input, durchführt und diese in bestimmte Zellen, auch wieder mit Bezügen, in einer Tabelle schreibt. Leider gibt er mir dabei ständig Fehler 6 "Überlauf" aus, obwohl meine Variablen mit Long groß genug sein dürften.
Hier der Script-Ausschnitt:
Dim maxzeile As Long
maxzeile = Sheets("Einlesen").Cells(Rows.Count, 1).End(xlUp).Row 'Ermittlung Anz der Messpunkte
Dim az2 As Long 'aktuelle Zeile 10 min Mittelung
Dim Az2z As Long 'Laufvariable für Zielzeile 10 min Mittelwerte
Dim az2h As Byte 'Laufvariable Zeilenvektor Harmonische Mittelwertbildung
Dim az2pro As Byte 'Laufvariable Zeilenvektor Prozentbildung
Dim az3 As Long 'aktuelle Zeile 1h Mittelung
Dim az4 As Long 'aktuelle Zeile 2h Mittelung
Dim UL1 As Double
Dim UL2 As Double
Dim UL3 As Double
With Sheets("Einlesen")
Az2z = 2
For az2 = 2 To maxzeile - 59 Step 60 ' alle Messwerte mit 10 min Mittelung
Sheets("GBerech").Cells(Az2z, 3).Value = .Cells(az2, 1).Value 'Datum
Sheets("GBerech").Cells(Az2z, 4).Value = Application.WorksheetFunction.Average(. _
Range(.Cells(az2, 2), .Cells(az2 + 59, 2))) 'U L1-L2
Sheets("GBerech").Cells(Az2z, 5).Value = Application.WorksheetFunction.Average(. _
Range(.Cells(az2, 3), .Cells(az2 + 59, 3))) 'U L2-L3
Sheets("GBerech").Cells(Az2z, 6).Value = Application.WorksheetFunction.Average(. _
Range(.Cells(az2, 4), .Cells(az2 + 59, 4))) 'U L3-L1
Sheets("GBerech").Cells(Az2z, 7).Value = Application.WorksheetFunction.Average(. _
Range(.Cells(az2, 22), .Cells(az2 + 59, 22))) 'Unsymmetrie
For az2h = 23 To 97 'Mittelwert Harmonische bilden
Cells(Az2z, az2h + 79).Value = Application.WorksheetFunction.Average(.Range(. _
Cells(az2, az2h), .Cells(az2 + 59, az2h)))
Next az2h
For az2pro = 109 To 180 Step 3 'Mittelwert in Prozentwert umwandeln bezogen auf die _
Grundschwingung
Sheets("GBerech").Cells(Az2z, az2pro - 101).Value = (.Cells(az2, az2pro). _
Value / .Cells(az2, 106).Value) * 100 'Harmonische U1
Sheets("GBerech").Cells(Az2z, az2pro - 100).Value = (.Cells(az2, az2pro + 1). _
Value / .Cells(az2, 106 + 1).Value) * 100 'Harmonische U2
Sheets("GBerech").Cells(Az2z, az2pro - 99).Value = (.Cells(az2, az2pro + 2). _
Value / .Cells(az2, 106 + 2).Value) * 100 'Harmonische U3
Next az2pro
Az2z = Az2z + 1
Next az2
Die Fehlerzeile ist fett markiert. Ich vermute mal, das meine Werte die ich übernehme für den Fehler verantwortlich sind, sicher bin ich mir da jedoch nicht. Kann da jemand Licht in mein VBA-Dunkel bringen und mir eine Lösungsstrategie nennen?Danke