Ich habe mal vor langer Zeit folgendes Makro geschrieben bekommen. Dabei wird ab Zeile 16 eine neue Zeile eingefügt und Zeile 16 dort komplett reinkopiert. Mein Problem ist nun, dass in Spalte G eine Berechnung stattfindet (=WENN(E160;G15-E16;"")), die 1:1 kopiert wird. Allerdings sind dadurch dann die Verweise falsch und das Ergebnis stimmt nicht mehr.
Ist es jemandem von Euch möglich, den Code entsprechend anzupassen, so dass die Formel relativ kopiert wird, also
=WENN(E170;G16-E17;"")
=WENN(E180;G17-E18;"")
usw.?
Für Hilfe wäre ich sehr dankbar, wie gesagt, ich habe von VBA überhaupt keine Ahnung :-(
MiraCeti
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo Errorhandler
eRow = [E65536].End(xlUp).Row - 5
If Target.Count > 1 Then Exit Sub
If Target.Row = eRow And Intersect(Target, Range("E:F")) Then
Application.EnableEvents = False
Rows(eRow + 1).Insert Shift:=xlDown
Rows(eRow + 2).Copy Rows(eRow + 1)
End If
Errorhandler:
Application.EnableEvents = True
End Sub
Sub lala()
Application.EnableEvents = True
Rows("17:17").Select
Selection.Insert Shift:=xlDown
Rows("16:16").Select
Selection.Copy
Rows("17:17").Select
ActiveSheet.Paste
Application.CutCopyMode = False
End Sub