Morning chaps,
I am quite happy to admit that I am rubbish with VBA code and therefore I need your help - I got this code from t'interweb:
Function ValidPostCode(ByVal PostCode As String) As Boolean
Dim Sections() As String
PostCode = UCase$(PostCode)
Sections = Split(PostCode)
If PostCode = "GIR 0AA" Or PostCode = "SAN TA1" Or _
(Sections(1) Like "#[A-Z][A-Z]" And _
(Sections(0) Like "[A-Z]#" Or Sections(0) Like "[A-Z]#[0-9ABCDEFGHJKSTUW]" Or _
Sections(0) Like "[A-Z][A-Z]#" Or Sections(0) Like "[A-Z][A-Z]#[0-9ABEHMNPRVWXY]")) Then
ValidPostCode = ((Sections(0) Like "[BEGLMSW]#*" Or _
Sections(0) Like "A[BL]#*" Or _
Sections(0) Like "B[ABDHLNRST]#*" Or _
Sections(0) Like "C[ABFHMORTVW]#*" Or _
Sections(0) Like "D[ADEGHLNTY]#*" Or _
Sections(0) Like "E[CHNX]#[AMNRVY]" Or _
Sections(0) Like "F[KY]#*" Or _
Sections(0) Like "G[LU]#*" Or _
Sections(0) Like "H[ADGPRSUX]#*" Or _
Sections(0) Like "I[GPV]#*" Or _
Sections(0) Like "K[ATWY]#*" Or _
Sections(0) Like "L[ADELNSU]#*" Or _
Sections(0) Like "M[EKL]#*" Or _
Sections(0) Like "N[EGNPRW]#*" Or _
Sections(0) Like "O[LX]#*" Or _
Sections(0) Like "P[AEHLOR]#*" Or _
Sections(0) Like "R[GHM]#*" Or _
Sections(0) Like "S[AEGKLMNOPRSTWY]#*" Or _
Sections(0) Like "T[ADFNQRSW]#*" Or _
Sections(0) Like "W[ACDFNRSV]#*" Or _
Sections(0) Like "UB#*" Or _
Sections(0) Like "YO#*" Or _
Sections(0) Like "ZE#*") And _
Sections(1) Like "*#[!CIKMOV][!CIKMOV]")
Else
ValidPostCode = False
End If
End Function
Which is then used in conjunction with a formula within conditionally formatting.
The stupid question is - is there anything within that code that indicates where the data is in the workbook?
I am quite happy to admit that I am rubbish with VBA code and therefore I need your help - I got this code from t'interweb:
Function ValidPostCode(ByVal PostCode As String) As Boolean
Dim Sections() As String
PostCode = UCase$(PostCode)
Sections = Split(PostCode)
If PostCode = "GIR 0AA" Or PostCode = "SAN TA1" Or _
(Sections(1) Like "#[A-Z][A-Z]" And _
(Sections(0) Like "[A-Z]#" Or Sections(0) Like "[A-Z]#[0-9ABCDEFGHJKSTUW]" Or _
Sections(0) Like "[A-Z][A-Z]#" Or Sections(0) Like "[A-Z][A-Z]#[0-9ABEHMNPRVWXY]")) Then
ValidPostCode = ((Sections(0) Like "[BEGLMSW]#*" Or _
Sections(0) Like "A[BL]#*" Or _
Sections(0) Like "B[ABDHLNRST]#*" Or _
Sections(0) Like "C[ABFHMORTVW]#*" Or _
Sections(0) Like "D[ADEGHLNTY]#*" Or _
Sections(0) Like "E[CHNX]#[AMNRVY]" Or _
Sections(0) Like "F[KY]#*" Or _
Sections(0) Like "G[LU]#*" Or _
Sections(0) Like "H[ADGPRSUX]#*" Or _
Sections(0) Like "I[GPV]#*" Or _
Sections(0) Like "K[ATWY]#*" Or _
Sections(0) Like "L[ADELNSU]#*" Or _
Sections(0) Like "M[EKL]#*" Or _
Sections(0) Like "N[EGNPRW]#*" Or _
Sections(0) Like "O[LX]#*" Or _
Sections(0) Like "P[AEHLOR]#*" Or _
Sections(0) Like "R[GHM]#*" Or _
Sections(0) Like "S[AEGKLMNOPRSTWY]#*" Or _
Sections(0) Like "T[ADFNQRSW]#*" Or _
Sections(0) Like "W[ACDFNRSV]#*" Or _
Sections(0) Like "UB#*" Or _
Sections(0) Like "YO#*" Or _
Sections(0) Like "ZE#*") And _
Sections(1) Like "*#[!CIKMOV][!CIKMOV]")
Else
ValidPostCode = False
End If
End Function
Which is then used in conjunction with a formula within conditionally formatting.
The stupid question is - is there anything within that code that indicates where the data is in the workbook?
Comment