Hello,
I'm trying to delete an entire row upon deletion of the contents in a cell:
If Not Intersect(target, Range("B:B")) Is Nothing Then
Set target = Intersect(target, Range("B:B"))
'If target Is Nothing Then Exit Sub
If target.count > 1 Then Exit Sub
For Each rngcell In target
If rngcell.Value = "" Then
'holds value
temp = target.Offset(1, -1).Value
target.Offset(0, -1).ClearContents
'delete active row
Rows(ActiveCell.Row).Select
Selection.Delete
'replace value with previously stored value
ActiveCell.Value = temp
'counter = counter - 1
'Range("f1") = counter
Else
target.Offset(0, -1).Value = counter
counter = counter + 1
Range("f1") = counter 'checkingvalue of counter
End If
Next
One of the issues I'm getting though is that if I delete the last value in a list Excel seems to get caught in a bit of a loop.
Any suggestions on how to fix this?
I'm trying to delete an entire row upon deletion of the contents in a cell:
If Not Intersect(target, Range("B:B")) Is Nothing Then
Set target = Intersect(target, Range("B:B"))
'If target Is Nothing Then Exit Sub
If target.count > 1 Then Exit Sub
For Each rngcell In target
If rngcell.Value = "" Then
'holds value
temp = target.Offset(1, -1).Value
target.Offset(0, -1).ClearContents
'delete active row
Rows(ActiveCell.Row).Select
Selection.Delete
'replace value with previously stored value
ActiveCell.Value = temp
'counter = counter - 1
'Range("f1") = counter
Else
target.Offset(0, -1).Value = counter
counter = counter + 1
Range("f1") = counter 'checkingvalue of counter
End If
Next
One of the issues I'm getting though is that if I delete the last value in a list Excel seems to get caught in a bit of a loop.
Any suggestions on how to fix this?