Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default 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.

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
Validation Question KLock Excel Discussion (Misc queries) 2 December 3rd 08 04:23 PM
Validation Question RJ Swain Excel Worksheet Functions 8 February 10th 08 10:49 PM
Validation Question SiH23 Excel Discussion (Misc queries) 2 September 16th 07 08:29 PM
validation question G Excel Discussion (Misc queries) 12 January 24th 06 10:55 PM
Validation Question....Can this be done? harpscardiff Excel Discussion (Misc queries) 2 January 11th 06 05:15 PM


All times are GMT +1. The time now is 12:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"