Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default checking a Cells contents

Hi,
Variations on a theme !

Private Sub Worksheet_Change(ByVal Target As Range)
Dim x, Ch
If Len(Target) < 9 Then GoTo Xit
For x = 1 To 9
Ch = Asc(Mid(Target, x, 1))
Select Case Ch
Case Is < 48, Is 57 '0 to 9
If x = 3 Then GoTo Xit
Case Is < 65, Is 90 'A to Z
'ALTERNATIVE Case Is < 65, 91 To 96, Is 122 'A to Z, a to z
If x < 3 Then GoTo Xit
End Select
Next x
Exit Sub
Xit:
Application.EnableEvents = False
MsgBox "Order is invalid"
Target.Select
Application.EnableEvents = True
End Sub

As is, 0 to 9 are allowed for the 3rd char. and A to Z for others.
If a to z are also permissible for others, change to the alternative given.

Regards,
Don

"antinoz" wrote in message
...
I'm trying to validate data in a column of cells to check that the format

is
"NNANNNNNN" (N= number A= Alpha I have) all the cell contents are

different
but have 9 characters containing the alphanumeric format as shown

I want to put it in an If statement:

so if cell A1 = mask "NNANNNNNNN" cell A2 = "Valid order"



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
checking a Cells contents Bob Kilmer Excel Programming 2 September 13th 04 06:41 AM
checking a Cells contents Dave Peterson[_3_] Excel Programming 1 September 9th 04 01:04 PM
checking a Cells contents Bob Kilmer Excel Programming 0 September 9th 04 03:02 AM
Checking contents Edgar Thoemmes Excel Programming 4 February 9th 04 02:01 AM
Checking contents Edgar Thoemmes[_2_] Excel Programming 5 February 3rd 04 02:56 PM


All times are GMT +1. The time now is 05:34 PM.

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

About Us

"It's about Microsoft Excel"