Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Address = .EntireRow.Address Or .Address = .EntireColumn.Address Then
If Not Target.Cells.Count = myTargetRowBlanks And Not Target.Cells.Count = myTargetColumnBlanks Then
If MsgBox("Er staat nog data in de te verwijderen rij(en)/kolom(men), toch verwijderen?", vbYesNo) = vbNo Then
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End If
End If
End With
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim ar As Range, r As Range, c As Range, WholeRow As Boolean, WholeColumn As Boolean
myTargetRowBlanks = 0
myTargetColumnBlanks = 0
For Each ar In Selection.Areas
If Not WholeRow Then WholeRow = ar.Columns.Count = Columns.Count
If Not WholeColumn Then WholeColumn = ar.Rows.Count = Rows.Count
Next
For Each ar In Selection.Areas
For Each r In ar.Rows
If WholeColumn Then Exit For
If WholeRow Then
myTargetRowBlanks = myTargetRowBlanks + WorksheetFunction.CountBlank(r)
Else
myTargetRowBlanks = myTargetRowBlanks + WorksheetFunction.CountBlank(r.EntireRow)
End If
Next
For Each c In ar.Columns
If WholeRow Then Exit For
If WholeColumn Then
myTargetColumnBlanks = myTargetColumnBlanks + WorksheetFunction.CountBlank(c)
Else
myTargetColumnBlanks = myTargetColumnBlanks + WorksheetFunction.CountBlank(c.EntireColumn)
End If
Next
Next
End Sub