Anwendungs oder objektorientierter Fehler :(
20.08.2004 17:47:00
ChrisNa
Ich bekomme einen Anwendungs oder objektorientierten Fehler bei meinen folgenden code.
<pre>
Private Sub skp()
'Variablen
Dim Jahreingabe As Integer
Dim zähler As Long
Dim kw As Integer
Jahreseingabe = 2004
ThisWorkbook.Worksheets(2).Cells.Delete
ThisWorkbook.Worksheets(2).Cells(1, 2).FormulaR1C1 = "=DATE(" & Jahreseingabe & ",1,1)"
zähler = 2
kw = 1
While Jahreseingabe + 1 > Year(ThisWorkbook.Worksheets(2).Cells(zähler - 1, 2).Value)
ThisWorkbook.Worksheets(2).Cells(zähler, 2).FormulaR1C1 = "=SUM(R[-1]C+1)"
If Weekday(ThisWorkbook.Worksheets(2).Cells(zähler, 2).Value) = 2 Then
If zähler > 9 Then
ThisWorkbook.Worksheets(2).Range(Cells(zähler, 1), Cells(zähler - 7, 1)).Select
With ThisWorkbook.Worksheets(2).Range(Cells(zähler, 1), Cells(zähler - 7, 1)).Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ThisWorkbook.Worksheets(2).Range(Cells(zähler, 1), Cells(zähler - 7, 1)).Select
Selection.FormulaR1C1 = "KW " & kw & ""
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Arial"
.FontStyle = "Standard"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
kw = kw + 1
End If
If zähler < 9 Then
#####################in dieser zeile bekomme ich den a oder o Fehler!###
ThisWorkbook.Worksheets(2).Range("A" & zähler - zähler & ":A" & zähler - 1 & "").Select
######################################
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 90
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ThisWorkbook.Worksheets(2).Range(Cells(zähler - zähler + 2, 1), Cells(zähler - zähler + 2, 1)).Select
Selection.FormulaR1C1 = "KW " & kw & ""
With ActiveCell.Characters(Start:=1, Length:=4).Font
.Name = "Arial"
.FontStyle = "Standard"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
kw = kw + 1
End If
End If
If Day(ThisWorkbook.Worksheets(2).Cells(zähler, 2).Value) = 2 Then
If zähler > 3 Then
ThisWorkbook.Worksheets(2).Cells(zähler - 1, 2).Select
'Selection.Insert Shift:=xlDown
Selection.AddItem = xlDown
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With
zähler = zähler + 1
End If
End If
zähler = zähler + 1
Wend
ThisWorkbook.Worksheets(2).Cells(zähler - 1, 2).Delete
ThisWorkbook.Worksheets(2).Cells(zähler - 1, 2).Select
Selection.Insert Shift:=xlDown
With Selection.Interior
.ColorIndex = 4
.Pattern = xlSolid
End With
With ThisWorkbook.Worksheets(2).Columns(2)
.NumberFormat = "ddd dd/mm/yyyy"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.AutoFit
End With
ThisWorkbook.Worksheets(2).Columns(2).Copy
With ThisWorkbook.Worksheets(2).Columns(2)
.PasteSpecial Paste:=xlValues ' Werte
.PasteSpecial Paste:=xlFormats ' Formate
End With
Application.CutCopyMode = False
End Sub</pre>
Ich finde einfach nicht heraus woran es liegt.
Kann mir da bitte wer weiter helfen?
Danke und ein schönes We im vorraus!
gruß
ChrisNa
ps. es ist noch nicht fertig nur ein teil - falls wer den sinn des ganzen sucht :)