mit unten stehendem Code füge ich Zeiten in Zellen ein. Geht auch wunderbar, bis auf die im Code markierten Stellen. Egal was ich dort eingebe, irow -3, irow -4,..., an der Zeile ändert sich nichts!!!
Was mache ich da falsch?
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim irow, icol As Long
Dim Bereich As Range
If Intersect(Target, Range("P6:P44,AH6:AH44, BS6:BS44, CK6:CK44, DV6:DV44, EN6:EN44,FY6:FY44, _
_
GQ6:GQ44, IB6:IB44, IT6:IT44, KG6:KG44, KY6:KY44, ML6:ML44, ND6:ND44,OQ6:OQ44,PI6:PI44")) Is _
Nothing Then Exit Sub
Application.EnableEvents = False
irow = ActiveCell.Row
icol = ActiveCell.Column
If Cells(irow - 1, icol) = "" Then
Application.EnableEvents = True
Dim zellinhalt As String
Dim i As Long
For i = 6 To 44
zellinhalt = Range("YA" & i).Value
If zellinhalt "" Then
With Range("H" & i)
.ClearComments
.AddComment
.Comment.Text Text:=zellinhalt
.Comment.Shape.TextFrame.AutoSize = True
End With
Else
End If
Next i
Exit Sub
End If
If Cells(irow - 1, icol).Value = Worksheets("Tabelle11").Cells(15, 1).Value Then
Cells(irow - 1, icol).Value = Worksheets("Tabelle11").Cells(15, 5).Value
Cells(irow - 1, icol + 1).Value = Worksheets("Tabelle11").Cells(15, 7).Value
Cells(irow, icol).Value = Worksheets("Tabelle11").Cells(15, 10).Value
Cells(irow, icol + 1).Value = Worksheets("Tabelle11").Cells(15, 11).Value
Cells(irow - 1, icol + 18).Value = Worksheets("Tabelle11").Cells(15, 12).Value 'richtige _
Spalte, falsche Zeile
Cells(irow - 1, icol + 19).Value = Worksheets("Tabelle11").Cells(15, 13).Value 'richtige _
Spalte, falsche Zeile
End If
... 'noch mehr Code
Application.EnableEvents = True
End Sub
Besten Gruß
Thorsten