Results 1 to 10 of 21

Thread: Validating PAN (Indian Format)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    8
    Rep Power
    0
    Hello Sir,

    I am talking about the VB code. which is as below given bu you.

    Function IsPAN(S As String) As String
    If Len(S) < 10 Then
    IsPAN = "Too short!"
    ElseIf Len(S) > 10 Then
    IsPAN = "Too long!"
    Else
    If Mid(S, 1, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 1 is not text."
    If Mid(S, 2, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 2 is not text."
    If Mid(S, 3, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 3 is not text."
    If Mid(S, 4, 1) Like "[!Pp]" Then IsPAN = IsPAN & vbLf & "Character 4 is not the letter 'P'."
    If Mid(S, 5, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 5 is not text."
    If Mid(S, 6, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 6 is not a number."
    If Mid(S, 7, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 7 is not a number."
    If Mid(S, 8, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 8 is not a number."
    If Mid(S, 9, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 9 is not a number."
    If Mid(S, 10, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 10 is not text."
    If Len(IsPAN) Then
    IsPAN = Mid(IsPAN, 2)
    Else
    IsPAN = "OK"
    End If
    End If
    End Function

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Quote Originally Posted by udaysdevadiga@gmail.com View Post
    Hello Sir,

    I am talking about the VB code. which is as below given bu you.

    Function IsPAN(S As String) As String
    If Len(S) < 10 Then
    IsPAN = "Too short!"
    ElseIf Len(S) > 10 Then
    IsPAN = "Too long!"
    Else
    If Mid(S, 1, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 1 is not text."
    If Mid(S, 2, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 2 is not text."
    If Mid(S, 3, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 3 is not text."
    If Mid(S, 4, 1) Like "[!Pp]" Then IsPAN = IsPAN & vbLf & "Character 4 is not the letter 'P'."
    If Mid(S, 5, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 5 is not text."
    If Mid(S, 6, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 6 is not a number."
    If Mid(S, 7, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 7 is not a number."
    If Mid(S, 8, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 8 is not a number."
    If Mid(S, 9, 1) Like "[!0-9]" Then IsPAN = IsPAN & vbLf & "Character 9 is not a number."
    If Mid(S, 10, 1) Like "[!A-Za-z]" Then IsPAN = IsPAN & vbLf & "Character 10 is not text."
    If Len(IsPAN) Then
    IsPAN = Mid(IsPAN, 2)
    Else
    IsPAN = "OK"
    End If
    End If
    End Function
    Okay, I think the best way to do what I think you want is to create a template. Start a new workbook and put the above code in a module in that new workbook, then use Save As to save the workbook as an Excel Macro Enabled Template (give it a name you will recognize). Now, the next time you start a workbook that needs the PAN functionality, select that template instead of a blank workbook and the function will be in place ready-to-use.

Similar Threads

  1. Validating PAN (Indian Format)
    By Admin in forum Test Area
    Replies: 30
    Last Post: 03-22-2023, 06:14 PM
  2. Validating PAN (Indian Format)
    By Admin in forum Test Area
    Replies: 20
    Last Post: 03-22-2023, 06:14 PM
  3. Validating PAN NUMBER Indian Format
    By mani780 in forum Excel Help
    Replies: 3
    Last Post: 03-10-2015, 01:19 PM
  4. Excel Number Format: Indian Style Comma Separation
    By Rick Rothstein in forum Rick Rothstein's Corner
    Replies: 6
    Last Post: 09-18-2013, 11:38 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •