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............
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............