Warme bakkertje
Meubilair
- Lid geworden
- 13 apr 2008
- Berichten
- 8.020
- Besturingssysteem
- Windows 10
- Office versie
- MO Home and Business 2024
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Variant
Application.ScreenUpdating = False
With Sheets("totaal")
.Unprotect "Davy"
.Range("A2:G" & .Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
For Each c In Sheets("uren").Range("B4:B150")
If c <> "" Then
.Cells(Rows.Count, 1).End(xlUp).Offset(1).Resize(, 2) = Cells(c.Row, 1).Resize(, 2).Value
.Cells(Rows.Count, 1).End(xlUp).Offset(, 2) = IIf(c.Offset(, 1) <> "", c.Offset(, 1).Value, c.Offset(, 4).Value)
End If
Next c
.Protect "Davy"
End With
Application.ScreenUpdating = True
End Sub
Code:
Private Sub Worksheet_Activate()
ActiveSheet.Unprotect "Davy"
Range("A2:C" & Cells(Rows.Count, 2).End(xlUp).Row).Sort [B1]
If [A52] <> "" Then
Range("A52:C" & Cells(Rows.Count, 1).End(xlUp).Row).Copy
Cells(2, 5).PasteSpecial xlPasteValues
Range("A52:C" & Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
End If
Application.CutCopyMode = False
ActiveSheet.Protect "Davy"
End Sub