Hello I need your help ro solve how to stop macro (do nothing) when user is selecting several rows in range and delete it.
I have simple code what execute on target cell value change. But i want this code not to rune when user deletes row what is containing this cell.
Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Dim lookupcell As Range
Dim cqty As Integer
Dim countifrange As Range
Set KeyCells = Range("c40:C100")
Set countifrange = Worksheets("Kaablid").Range("A2:A500")
If Not Application.Intersect(KeyCells, Range(Target.Address)) _
Is Nothing Then
Set lookupcell = Worksheets("Kaablid").Range("A2:A500").Find(Target)
cqty = Application.WorksheetFunction.CountIf(countifrange, Target)
If cqty = 0 Then Exit Sub
Application.EnableEvents = False
ActiveCell.EntireRow.Offset(1).Resize(cqty).Insert Shift:=xlDown
Application.EnableEvents = True
End If
End Sub
Bookmarks