Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VALIDATION FUNCTION HELP 2...
How can I use validation to stop users from entering the following
characters?: / \ : * ? " < | |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Data Validation & If function | Excel Worksheet Functions | |||
Excel Data Validation/Lookup function does function correcty | Excel Worksheet Functions | |||
VALIDATION FUNCTION HELP | Excel Programming | |||
VALIDATION FUNCTION HELP | Excel Programming | |||
Validation and IF function | Excel Discussion (Misc queries) |