Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 64
Default VALIDATION FUNCTION HELP 2...

How can I use validation to stop users from entering the following
characters?: / \ : * ? " < |
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 471
Default VALIDATION FUNCTION HELP 2...

Place this code on the sheet you wish to bar the entry on in the Microsoft
Excel Objects Section of the VBAProject:

Public DontCall As Integer
Public LastCol As Double
Public LastRow As Double


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim X As Double
Dim ans As Variant
If DontCall = 1 Then
DontCall = 0
GoTo endingout
End If
If LastRow = 0 Then
LastRow = ActiveCell.Row
End If
If LastCol = 0 Then
LastCol = ActiveCell.Column
End If
X = 0
Let X = InStr(1, Cells(LastRow, LastCol).Value, "/")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Forward Slash (/). Please
change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, "\")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a BackSlash (/). Please
change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, "*")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Splat (*). Please
change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, Chr(34))
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Double Quotation Mark.
Please change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, "<")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Less Than Symbol (<).
Please change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, "")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Greater Than Symbol
(). Please change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If
If X = 0 Then
Let X = InStr(1, Cells(LastRow, LastCol).Value, "|")
If X 0 Then
ans = MsgBox(prompt:="You should NOT enter a Pipe Symbol (|).
Please change it!", Title:="Big Problem!", Buttons:=vbCritical)
DontCall = 1
Cells(LastRow, LastCol).Select
GoTo endingout
End If
End If


LastRow = ActiveCell.Row
LastCol = ActiveCell.Column

endingout:


End Sub


"KLZA" wrote:

How can I use validation to stop users from entering the following
characters?: / \ : * ? " < |

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
Data Validation & If function Opal Excel Worksheet Functions 1 August 24th 09 09:43 PM
Excel Data Validation/Lookup function does function correcty Kirkey Excel Worksheet Functions 2 May 25th 09 09:22 PM
VALIDATION FUNCTION HELP KLZA Excel Programming 1 May 21st 08 07:27 PM
VALIDATION FUNCTION HELP KLZA Excel Programming 1 May 14th 08 04:23 PM
Validation and IF function Anne Spencer Excel Discussion (Misc queries) 1 March 5th 08 09:10 AM


All times are GMT +1. The time now is 01:00 PM.

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"