Krulle1000
New Member
- Joined
- Feb 25, 2016
- Messages
- 15
Hello,
I use data validation with a list of values (--Select--;1;2;3) for all cells in range "B7:E1006".
The default value should be --select-- .
With the vba code below: If someone hits the delete button the cell will become empty but refills with --select--.
That works fine, but if 2 or more cells are selected and deleted, the cells become empty
Vba gives a 'type mismatch' error on line 'If IsEmpty(.Value) then'
How can I prevent empty cells when hitting the delete button or how can I refill all empty cells with my default value --Select-- ?
If Not (Application.Intersect(Target, Range("B7:E1006")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
location = .Address(RowAbsolute:=False, ColumnAbsolute:=False)
Sheet2.Range(location) = "'--Select--"
End If
Application.EnableEvents = True
End If
End With
End If
Thanks.
I use data validation with a list of values (--Select--;1;2;3) for all cells in range "B7:E1006".
The default value should be --select-- .
With the vba code below: If someone hits the delete button the cell will become empty but refills with --select--.
That works fine, but if 2 or more cells are selected and deleted, the cells become empty

Vba gives a 'type mismatch' error on line 'If IsEmpty(.Value) then'
How can I prevent empty cells when hitting the delete button or how can I refill all empty cells with my default value --Select-- ?
If Not (Application.Intersect(Target, Range("B7:E1006")) _
Is Nothing) Then
With Target
If Not .HasFormula Then
Application.EnableEvents = False
If IsEmpty(.Value) Then
location = .Address(RowAbsolute:=False, ColumnAbsolute:=False)
Sheet2.Range(location) = "'--Select--"
End If
Application.EnableEvents = True
End If
End With
End If
Thanks.