![]() |
Validation Question
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. |
Validation Question
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. |
All times are GMT +1. The time now is 12:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com