LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Preventing Invalid Characters using data Validation

How about event code that strips out all but numerics or alphas as you enter
data?

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
Dim i As Long
Dim sChar As String
Dim sTemp As String
On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
With Target
For i = 1 To Len(.Text)
sChar = Mid(.Text, i, 1)
If sChar Like "[0-9a-zA-Z]" Then _
sTemp = sTemp & sChar
Next i
.Value = sTemp
End With
End If
ws_exit:
Application.EnableEvents = True
End Sub


Gord Dibben MS Excel MVP

On Mon, 30 Apr 2007 11:30:01 -0700, NLiles
wrote:

Is this something that cannot be done?.. I see lots of peoples questions
being answered but not mine :)..

Thanks


"NLiles" wrote:

I'm trying to create a template for users to enter data and have it input
onto a spreadsheet, there are some conditions i need to set using data
validation and im not sure how to do it.. There cannot be any
spaces,-,&,%,#... etc.. in the fields, but Numeric and Alpha are ok. There
also can only be 10 characters in the field which is easy to define. I tried
using the custom validation but I’m not familiar with how to create a formula
to achieve this goal.


 
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 invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Worksheet Functions 0 November 7th 06 12:54 PM
data validation invalid in dynamic validation list ilia Excel Programming 0 November 7th 06 12:54 PM
Data Validation not preventing invalid entries Denise Excel Discussion (Misc queries) 2 April 6th 06 10:55 PM
Data Validation preventing ISTEXT() from reading FALSE in '97 Adam Kroger Excel Discussion (Misc queries) 2 November 28th 05 12:34 PM


All times are GMT +1. The time now is 11:59 AM.

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"