Intersect also working with Delete key

placasse

Board Regular
Joined
Jun 14, 2010
Messages
90
Hi,
I have this macro that intersects any time a value is changed within a specific range. Everything works fine except it doesn't run when I hit the Del key on any of the cells of that range.

How do we make it work so it will Intersect on Del key too ?


Part of my code:

Dim keycells As Range
Set keycells = Worksheets("$can").Range("013:0312")
If Not Intersect(keycells, Range(Target.Address)) Is Nothing Then

Thank you for your help

Pierre
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Works for me when part of a Worksheet_Change event code in sheet "$can" when I delete something in rows 13:312.

Can you confirm that
- this is part of Worksheet_Change event code?
- the code is in the "$can" sheet module?

I tested with this code (though the code could be simplified a little)
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim keycells As Range
    
    Set keycells = Worksheets("$can").Range("013:0312")
    If Not Intersect(keycells, Range(Target.Address)) Is Nothing Then
        MsgBox "code fired"
    End If
End Sub
 
Upvote 0
Hi,
thank you for the reply.

I tested it into a different worksheet and like you said, it is working

I found out that I had this line in $can sheet code:
Application.OnKey Key:="{DEL}", Procedure:="AlertUser"
Which I think disable the del key. If I remark the line, it works fine.

Now I will have to find a way to put it on or off depending where I am in the code.

Thank you

Pierre
 
Upvote 0
Hi again,
I was able to enable the Delete key to work within my code.

Do you know a simple way of detecting within the Worksheet_Event when the Delete key is depressed so I could run other code when this happens ?

Thank you Pierre
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top