Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I disallow certain characters in a cell? I don't want the user to
enter single quotations, commas, and & in the cells of a particular column. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here is some code that will catch when a user enters a value with one of the
offending characters in column B (2)... Private Sub Worksheet_Change(ByVal Target As Range) Dim blnIsOk As Boolean blnIsOk = True If Target.Column = 2 Then If InStr(1, Target.Value, "'") Then blnIsOk = False ElseIf InStr(1, Target.Value, ",") Then blnIsOk = False ElseIf InStr(1, Target.Value, "&") Then blnIsOk = False End If End If If Not blnIsOk Then MsgBox "That is not a valid input." Application.Undo End If End Sub -- HTH... Jim Thomlinson "Nathaniel W. Polky" wrote: How do I disallow certain characters in a cell? I don't want the user to enter single quotations, commas, and & in the cells of a particular column. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Validation Question | Excel Discussion (Misc queries) | |||
Validation Question | Excel Worksheet Functions | |||
Validation Question | Excel Discussion (Misc queries) | |||
validation question | Excel Discussion (Misc queries) | |||
Validation Question....Can this be done? | Excel Discussion (Misc queries) |