View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Anne Troy[_2_] Anne Troy[_2_] is offline
external usenet poster
 
Posts: 221
Default delete row base the value of certain column

Try this, wesbird: http://www.vbaexpress.com/kb/getarticle.php?kb_id=260
*******************
~Anne Troy

www.OfficeArticles.com
www.MyExpertsOnline.com


"wesbird" wrote in message
...
Hi How are you?
My customer report this to me, he delete some row by mistake using hot

key
Ctrl-D. he want me to put code to prevent it happening. What I shold do

it,
check a certain column (e.g. column ZZ), if there are value, DO NOT delete
this row. cancel the deletion. if it is empty, it is fine to delete.
after some research, here is my plan,
1. assign Ctrl-D to my DoNothing routine,
2. in Worksheet_SelectionChange function, I will check if a value in
column ZZ, yes, I am not change hot key assignment by
Application.OnKey "^{d}", ""
no, I will assign Ctrl-D back to Delete row by
Application.OnKey "^{d}", "InsertProc"
Now my problem is, I do not how to do that. which command string should I
use in the place of "InsertProc". Your help will be deeply appreciated.
aboud my solution, if you have any idea, suggestion, advice, anything, I
would love to hear.



Thank you and have nice day.
Wes






code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target(1, 1).Value < "" Then
Application.OnKey "^{d}", ""
MsgBox "disable"
Else
Application.OnKey "^{d}", "InsertProc" ' <- here is my question
MsgBox "enable"
End If
End Sub

Public Sub Donothing()
MsgBox "Here is my DoNothing"
End Sub