Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1104to1108
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Laufzeitfehler '5'! Woran kann das liegen?

Laufzeitfehler '5'! Woran kann das liegen?
Stefan
Hallo liebe Programmiergemeinde.
Ich habe auf Excel-Basis ein Programm entworfen das ich mittels VBA fülle.
Ich kann je nach Bedarf ein Rechenblock hinzufügen oder auch wieder entfernen. Ein Rechenblock besitzt 2 Spalten und geht von Zeile 4 bis 258. Ein neu eingefügter Rechenblock wird dann mittels VBA-Makro mit Formeln gefüllt. Das funktioniert soweit auch zu 100%.
Jetzt tritt allerdings folgendes Problem auf:
Wenn ich ab Spalte Z einen neuen Rechenblock hinzufüge, also in Spalte AA und AB einfüge bekomme ich den "Laufzeitfehler '5' - Ungültiger Prozeduraufruf oder ungültiges Argument". Das interessante an dem Fehler ist zusätzlich noch, dass der Fehler erst ab Zeile 100 auftritt. Das bedeutet, für alle Formeln die ich von Zeile 4-99 in den Rechenblock schreibe ist alles super. Sobald ich die allerdings gleiche Formel ab Zeile 100 in eine Zelle schreibe tritt der oben beschriebene Laufzeitfehler auf. Der Fehler tritt also in Kombination ab Spalte AA und Zeile größer 99 auf.
Woran kann das liegen? Ich bin echt ratlos.
Ich hoffe auf eure Hilfe.
Stefan
der Code wäre hilfreich oT.
21.09.2009 10:01:53
Tino
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 10:06:19
Jens
Hallo Stefan
Ohne den Code zu sehen, etwas schwer, etwas zu sagen.
Ich vermute mal, (je nachdem, wie komplex die Formeln sind, dass Du dort an irgendwelche Grenzen von Excel stößt (siehe auch hier: http://www.xlam.ch/ ).
Gruß aus dem Sauerland
Jens
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 10:16:30
Stefan
Hier mal die Formeln die ich in die Zellen schreibe. Nur die letzte Formel macht Probleme, da sie in einer Zeile größer Zeile 99 und größer Spalte Z steht.
Cells(7, spaltenanzahl + 5).Formula = "=((" & Cells(18, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$18)+(" & Cells(40, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$40)+(" & Cells(63, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$63)+(" & Cells(82, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$82)+(" & Cells(94, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$94)+(" & Cells(120, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$120))*(" & Cells(6, spaltenanzahl + 5).AddressLocal(False, False) & "-" & Cells(6, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(9, spaltenanzahl + 5).Formula = "=(" & Cells(7, spaltenanzahl + 5).AddressLocal(False, False) & ")/($J$146*(" & Cells(6, spaltenanzahl + 5).AddressLocal(False, False) & "-" & Cells(6, spaltenanzahl + 4).AddressLocal(False, False) & "))"
Cells(18, spaltenanzahl + 5).Formula = "=($H$19*" & Cells(19, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$26*" & Cells(26, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$32*" & Cells(32, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(40, spaltenanzahl + 5).Formula = "=($H$41*" & Cells(41, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$49*" & Cells(49, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$56*" & Cells(56, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(63, spaltenanzahl + 5).Formula = "=($H$64*" & Cells(64, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$70*" & Cells(70, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$76*" & Cells(76, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(82, spaltenanzahl + 5).Formula = "=($H$83*" & Cells(83, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$89*" & Cells(89, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(94, spaltenanzahl + 5).Formula = "=($H$95*" & Cells(95, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$101*" & Cells(101, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$106*" & Cells(106, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$112*" & Cells(112, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(120, spaltenanzahl + 5).Formula = "=($H$121*" & Cells(121, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$133*" & Cells(133, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$139*" & Cells(139, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Anzeige
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 10:17:22
Stefan
Hier mal die Formeln die ich in die Zellen schreibe. Nur die letzte Formel macht Probleme, da sie in einer Zeile größer Zeile 99 und größer Spalte Z steht.
Cells(7, spaltenanzahl + 5).Formula = "=((" & Cells(18, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$18)+(" & Cells(40, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$40)+(" & Cells(63, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$63)+(" & Cells(82, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$82)+(" & Cells(94, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$94)+(" & Cells(120, spaltenanzahl + 5).AddressLocal(False, False) & "*$J$120))*(" & Cells(6, spaltenanzahl + 5).AddressLocal(False, False) & "-" & Cells(6, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(9, spaltenanzahl + 5).Formula = "=(" & Cells(7, spaltenanzahl + 5).AddressLocal(False, False) & ")/($J$146*(" & Cells(6, spaltenanzahl + 5).AddressLocal(False, False) & "-" & Cells(6, spaltenanzahl + 4).AddressLocal(False, False) & "))"
Cells(18, spaltenanzahl + 5).Formula = "=($H$19*" & Cells(19, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$26*" & Cells(26, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$32*" & Cells(32, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(40, spaltenanzahl + 5).Formula = "=($H$41*" & Cells(41, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$49*" & Cells(49, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$56*" & Cells(56, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(63, spaltenanzahl + 5).Formula = "=($H$64*" & Cells(64, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$70*" & Cells(70, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$76*" & Cells(76, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(82, spaltenanzahl + 5).Formula = "=($H$83*" & Cells(83, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$89*" & Cells(89, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(94, spaltenanzahl + 5).Formula = "=($H$95*" & Cells(95, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$101*" & Cells(101, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$106*" & Cells(106, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$112*" & Cells(112, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Cells(120, spaltenanzahl + 5).Formula = "=($H$121*" & Cells(121, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$133*" & Cells(133, spaltenanzahl + 4).AddressLocal(False, False) & ")+($H$139*" & Cells(139, spaltenanzahl + 4).AddressLocal(False, False) & ")"
Anzeige
kann so keinen Fehler feststellen oT. offen
21.09.2009 10:34:46
Tino
AW: kann so keinen Fehler feststellen oT. offen
21.09.2009 10:43:57
Stefan
ich leider auch. ich habe grade auch nochmal vieles ausprobiert.
sogar wenn ich
Range("AA100")= "=A01"
schreibe kommt der Fehler.
Wenn ich
Range("AA99")= "=A01"
schreibe funktioniert das.
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 10:49:13
David
Hallo Stefan,
da der Fehler offensichtlich dann auftritt, wenn sich die Zeilen von 2- auf 3-stellig ändern sowie die Spalten von 1- auf 2-stellig, vermute ich, dass es damit zu tun hat.
Du verwendest in deinen Formel einmal "Formula" und zum anderen "AddressLocal", dort wäre mein Ansatzpunkt.
Meine VBA-Kenntnisse sind recht begrenzt, aber ich finde, die Stelle, an der der Fehler auftritt, ist zu spezifisch, um ein Zufall zu sein.
Ohne die Tabelle und den kompletten Code wird man allerdings aus der Ferne nichts genaueres sagen können.
Gruß
David
Anzeige
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 11:39:46
Stefan
Fehler gefunden :-)
Der Fehler war in einem übergeordneten Worksheet-Code
ich muss in der If-Abfrage die Zahl 6 auf 8 abändern und es läuft.
If Len(Target.Address) > 8 Then ~f~
adr = Left(Target.Address, InStr(1, Target.Address, ":", vbTextCompare) - 1)
Else
adr = Target.Address
End If
~f~If Len(Target.Address) > 8 Then
adr = Left(Target.Address, InStr(1, Target.Address, ":", vbTextCompare) - 1)
Else
adr = Target.Address
End If
If Not Range(adr).Comment Is Nothing Then
....
AW: Laufzeitfehler '5'! Woran kann das liegen?
21.09.2009 12:35:53
David
Also doch die Ursache in der Anzahl der Stellen für Zeile/Spaltenbeschriftung!
Gruß
David
Anzeige

2 Forumthreads zu ähnlichen Themen


Hallo
ich habe hier im Forum öffters mal was für mich nützliches gefunden,habe aber selbst noch nie was gefragt. Heute aber brauche ich eure Hilfe... Public Sub Start() Dim activeWS, pruefen As String Dim tabellenblatt As Integer Dim sPfad As String Dim sDatei As Variant sPfad = "E:\Testo...
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige