Custome Validations Using Data->Validation->Custom

ban
05-27-2008, 09:21 PM
Hi

In my Excel Sheet some cells have validations like length must be 10,only numeric characters should be entered and a valid postcode ..... For all other validations except Postcode Iam doing it using Data-Validation Formulae. For POstCode I am doing the validation using VBA code like this .................


Private Function Postcode_Exit(ByVal Target As String)
Target = UCase(Target)
If Len(Target) < 1 Then Exit Function
With CreateObject("VBScript.RegExp")
.Pattern = "^[A-Z]{2}\d{2}\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]\d{2}\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]\d\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]{2}\d\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]{2}\d[A-Z]\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]\d[A-Z]\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]{2}\d{2}[A-Z]\s\d[A-Z]{2}$"
If Not .test(Target) Then
.Pattern = "^[A-Z]\d{2}[A-Z]\s\d[A-Z]{2}$"
If Not .test(Target) Then

Postcode_Exit = False
Exit Function
End If
End If
End If
End If
End If
End If
End If
End If
End With
Postcode_Exit = True
End Function



Can I do this using Data- validation Formula?????????

Anyone Please help me............

ban
05-27-2008, 11:00 PM
I also want to know the formula for

Even numers: Accepts only even numbers.
Multiple of 10 : accepts multiples of 10......

Thanks in advance......

Colin Legg
05-28-2008, 02:02 AM
I also want to know the formula for

Even numers: Accepts only even numbers.
Multiple of 10 : accepts multiples of 10......

Thanks in advance......

For even numbers, check out the ISEVEN worksheet function in your Excel Helpfile. It requires the Analysis ToolPak add-in.
Or you could use the INT function in a similar fashion to that demonstrated below.

For multiples of 10, one way would be to use the INT worksheet function like this (data validation in B3):

=INT(B3/10)=B3/10


Colin

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum