KP_SoCal
Board Regular
- Joined
- Nov 17, 2009
- Messages
- 116
For colums A,B,C,G,H on my worksheet, I would like to create an error message when users press the [SPACE BAR] when inside any one of the cells for these columns. The message would prompt them that entries using the [SPACE BAR] are not allowed.
I took a stab at this by writing the following code below, but it did not work for me. Any ideas on how to accomplish this? Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
If KeyAscii = 32 Then
MsgBox "Space is not allowed!", vbOKOnly
Application.EnableEvents = Flase
Application.Undo
Application.EnableEvents = True
Else
End If
End Sub
I took a stab at this by writing the following code below, but it did not work for me. Any ideas on how to accomplish this? Thanks!
Private Sub Worksheet_Change(ByVal Target As Range)
If KeyAscii = 32 Then
MsgBox "Space is not allowed!", vbOKOnly
Application.EnableEvents = Flase
Application.Undo
Application.EnableEvents = True
Else
End If
End Sub