Kopier koden her under.
I Excel:
Højre-klik på Ark1, vælg "Vis programkode"
Tryk ctrl+v og luk på det røde kryds.
Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
Application.EnableEvents = False 'For at undgå at koden looper
On Error GoTo Slut
homeArk = ActiveSheet.Name
If Target.Column = 6 And Target.Text = "Arbejdsweekend" Then
Target.EntireRow.Cut
Worksheets(2).Select
Worksheets(2).Range("F65536").End(xlUp).Offset(1, -5).Select
ActiveSheet.Paste
Worksheets(2).Range("F65536").End(xlUp).Offset(0, -5).Select
Worksheets(homeArk).Select
If ActiveCell.Value = "" Then
Selection.EntireRow.Delete Shift:=xlUp
Else
Selection.Offset(-1, 0).EntireRow.Delete Shift:=xlUp
Selection.Offset(-1, 0).Select
End If
End If
If Target.Column = 6 And Target.Text = "Løst" Then
Target.EntireRow.Cut
Worksheets(3).Select
Worksheets(3).Range("F65536").End(xlUp).Offset(1, -5).Select
ActiveSheet.Paste
Worksheets(3).Range("F65536").End(xlUp).Offset(0, -5).Select
Worksheets(homeArk).Select
If ActiveCell.Value = "" Then
Selection.EntireRow.Delete Shift:=xlUp
Else
Selection.Offset(-1, 0).EntireRow.Delete Shift:=xlUp
Selection.Offset(-1, 0).Select
End If
End If
Slut:
Application.ScreenUpdating = True
Application.EnableEvents = True 'For at undgå at koden looper
End Sub