Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default "delete" key activates Sub Worksheet_Change

I have a form that does not allow users to input a "#"
symbol in three cells. The code below accomplishes this.
Trouble is using the "delete" key in any cell anywhere in
my form pulls up the MsgBox from my "Private Sub
Worksheet" below.

Any help would be appreciated.



Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # "
Target = ""

End If
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "delete" key activates Sub Worksheet_Change

I pasted your code into a sheet module and couldn't reproduce the problem.

I did add a line to turn events back on at the end.

--
Regards,
Tom Ogilvy

"Dave" wrote in message
...
I have a form that does not allow users to input a "#"
symbol in three cells. The code below accomplishes this.
Trouble is using the "delete" key in any cell anywhere in
my form pulls up the MsgBox from my "Private Sub
Worksheet" below.

Any help would be appreciated.



Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # "
Target = ""

End If



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default "delete" key activates Sub Worksheet_Change

Thanks Tom, I only posted part of the code and after
further testing I realize that the entire code is creating
the trouble. Still don't know what it is but here is the
entire code.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # < ? [ ] : * \ and / "
Target = ""

End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "<") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "?") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "[") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If


If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "]") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, ":") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "*") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "\") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "/") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If


Application.EnableEvents = True
End Sub


-----Original Message-----
I pasted your code into a sheet module and couldn't

reproduce the problem.

I did add a line to turn events back on at the end.

--
Regards,
Tom Ogilvy

"Dave" wrote in

message
...
I have a form that does not allow users to input a "#"
symbol in three cells. The code below accomplishes this.
Trouble is using the "delete" key in any cell anywhere

in
my form pulls up the MsgBox from my "Private Sub
Worksheet" below.

Any help would be appreciated.



Private Sub Worksheet_Change(ByVal Target As

Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # "
Target = ""

End If



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default "delete" key activates Sub Worksheet_Change

There is nothing in your complete code that would cause that and it works
fine for me. I can't reproduce the behavior.

--
Regards,
Tom Ogilvy

wrote in message
...
Thanks Tom, I only posted part of the code and after
further testing I realize that the entire code is creating
the trouble. Still don't know what it is but here is the
entire code.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # < ? [ ] : * \ and / "
Target = ""

End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "<") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "?") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "[") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If


If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "]") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, ":") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "*") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "\") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "/") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! ""# < ? [ ] : * \ and /"" "
Target = ""
End If


Application.EnableEvents = True
End Sub


-----Original Message-----
I pasted your code into a sheet module and couldn't

reproduce the problem.

I did add a line to turn events back on at the end.

--
Regards,
Tom Ogilvy

"Dave" wrote in

message
...
I have a form that does not allow users to input a "#"
symbol in three cells. The code below accomplishes this.
Trouble is using the "delete" key in any cell anywhere

in
my form pulls up the MsgBox from my "Private Sub
Worksheet" below.

Any help would be appreciated.



Private Sub Worksheet_Change(ByVal Target As

Excel.Range)

On Error Resume Next

Application.EnableEvents = False

If Union(Target, Me.Range("AH3,I11,T11")).Address =
Me.Range("AH3,I11,T11").Address _
And InStr(1, Target, "#") 0 Then
Target.Select
MsgBox "The following symbols are not allowed in this
field! # "
Target = ""

End If



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Excel "Move or Copy" and "Delete" sheet functions dsiama Excel Worksheet Functions 1 December 28th 07 01:57 PM
change "true" and "false" to "availble" and "out of stock" inthestands Excel Worksheet Functions 2 July 19th 07 07:05 PM
How do I make a "Worksheet_Change event" to show any changes to cells? [email protected] Excel Worksheet Functions 2 April 26th 06 06:28 PM
Worksheet_Change Event "Circular Reference" Vyyk Drago Excel Programming 2 July 19th 03 03:31 PM


All times are GMT +1. The time now is 12:46 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"