Results 1 to 8 of 8

Tool to lookup policy numbers when given a string to decode

Threaded View

  1. #1
    Registered User
    Join Date
    03-10-2016
    Location
    Spokane, WA
    MS-Off Ver
    2010
    Posts
    5

    Tool to lookup policy numbers when given a string to decode

    Hello Forum,

    I am a first time poster, long time viewer. I have been a techie for a long time, but never thought myself a programmer. I currently work for a fortune 100 Insurance company as a lower-man on the totem pole, looking to develop this tool to take a lot of the waste out of the process, make it better for our customers, and cut down on wasted labor costs. This being said, this code is mostly what I have taught myself, through some old school text books and from Google. So here is what I have started, I understand the formatting will likely make the more tenured folks have meltdown, so I am open to any revisements, BUT I am most interested in how to get the main tool to reference back and forth between worksheets.

    I had been working on only one sheet in the workbook, and it was working fine. I have 15 cells ready for input, when the go button is selected it takes these cells and searches a table of example policy numbers and should bring up a message box with the department this is and the phone number to call. I started wanting it to just highlight the section where it explains the formatting of the number given, but think in order for the higher-ups to want to take it and run, it will need to be relatively polished and require little training... haha. So with all that, here is the code.

    Function IsLetter(strValue As String) As Boolean
        Dim intPos As Integer
        For intPos = 1 To Len(strValue)
            Select Case Asc(Mid(strValue, intPos, 1))
                Case 65 To 90, 97 To 122
                    IsLetter = True
                Case Else
                    IsLetter = False
                    Exit For
            End Select
         Next
        End Function
            
        
    Sub Button1_Click()
     Dim pos1 As String, pos2 As Variant, pos3 As Variant, pos4 As String, pos5 As Variant
     Dim pos6 As Variant, pos7 As Variant, pos8 As Variant, pos9 As Variant, pos10 As Variant
     Dim pos11 As Variant, pos12 As Variant, pos13 As Variant, pos14 As Variant, pos15 As Variant
     Dim numCheck1 As Boolean, numCheck2 As Boolean, numCheck3 As Boolean, numCheck4 As Boolean, numCheck5 As Boolean
     Dim numCheck6 As Boolean, numCheck7 As Boolean, numCheck8 As Boolean, numCheck9 As Boolean, numCheck10 As Boolean
     Dim numCheck11 As Boolean, numCheck12 As Boolean, numCheck13 As Boolean, numCheck14 As Boolean, numCheck15 As Boolean
     Dim letterCheck1 As Boolean, letterCheck2 As Boolean, letterCheck3 As Boolean, letterCheck4 As Boolean, letterCheck5 As Boolean
     Dim letterCheck6 As Boolean, letterCheck7 As Boolean, letterCheck8 As Boolean, letterCheck9 As Boolean, letterCheck10 As Boolean
     Dim letterCheck11 As Boolean, letterCheck12 As Boolean, letterCheck13 As Boolean, letterCheck14 As Boolean, letterCheck15 As Boolean
       '' pos1 = Worksheets("Long").Cells(M5): pos2 = Worksheets("Long").Range(N5).Value: pos3 = Worksheets("Long").Range(O5).Value
        pos4 = Worksheets("Long").Cells(P5).Value: Worksheets("Long").Range(Q5).Value: pos6 = Worksheets("Long").Range(R5).Value
        pos7 = Worksheets("Long").Range(S5).Value: Worksheets("Long").Range(T5).Value: pos9 = Worksheets("Long").Range(U5).Value
        pos10 = Worksheets("Long").Range(V5).Value: Worksheets("Long").Range(W5).Value: pos12 = Worksheets("Long").Range(X5).Value
        pos13 = Worksheets("Long").Range(Y5).Value: Worksheets("Long").Range(Z5).Value: pos15 = Worksheets("Long").Range(AA5).Value
        numCheck1 = IsNumeric(pos1)
        numCheck2 = IsNumeric(pos2)
        numCheck3 = IsNumeric(pos3)
        numCheck4 = IsNumeric(pos4)
        numCheck5 = IsNumeric(pos5)
        numCheck6 = IsNumeric(pos6)
        numCheck7 = IsNumeric(pos7)
        numCheck8 = IsNumeric(pos8)
        numCheck9 = IsNumeric(pos9)
        numCheck10 = IsNumeric(pos10)
        numCheck11 = IsNumeric(pos11)
        numCheck12 = IsNumeric(pos12)
        numCheck13 = IsNumeric(pos13)
        numCheck14 = IsNumeric(pos14)
        numCheck15 = IsNumeric(pos15)
        letterCheck1 = IsLetter(pos1)
        letterCheck2 = IsLetter(pos2)
        letterCheck3 = IsLetter(pos3)
        letterCheck4 = IsLetter(pos4)
        letterCheck5 = IsLetter(pos5)
        letterCheck6 = IsLetter(pos6)
        letterCheck7 = IsLetter(pos7)
        letterCheck8 = IsLetter(pos8)
        letterCheck9 = IsLetter(pos9)
        letterCheck10 = IsLetter(pos10)
        letterCheck11 = IsLetter(pos11)
        letterCheck12 = IsLetter(pos12)
        letterCheck13 = IsLetter(pos13)
        letterCheck14 = IsLetter(pos14)
        letterCheck15 = IsLetter(pos15)
    
       'Small Business Service Center'
        '3 letter, 8 number, with one character that can be skipped as an erroneous space and still generate correct value'
        If letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And pos4 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '3 letter, 7 number, with one character that can be skipped as an erroneous space and still generate correct value'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And pos4 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '2 letter, 8 number, with one character that can be skipped as an erroneous space and still generate correct value'
        ElseIf letterCheck1 = True And letterCheck2 = True And pos3 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '2 letter, 7 number, with one character that can be skipped as an erroneous space and still generate correct value'
        ElseIf letterCheck1 = True And letterCheck2 = True And pos3 = "" And pos11 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '3 letter, 8 number'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And letterCheck5 = False And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '3 letter, 7 number'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And letterCheck5 = False And pos11 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '2 letter, 8 number'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck5 = False And pos11 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
        '2 letter, 7 number'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck5 = False And pos10 = "" And pos11 = "" And pos12 = "" And pos13 = "" And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A47:I49").Select
       
       'Legacy Safeco Commercial'
       ElseIf numCheck1 = True And numCheck2 = True And letterCheck3 = True And letterCheck4 = True Then
        Worksheets("Long").Range("A50:I52").Select
       ElseIf numCheck1 = True And numCheck2 = True And pos3 = "-" And letterCheck4 = True And letterCheck5 = True Then
        Worksheets("Long").Range("A50:I52").Select
        
        'Middle Markets'
        ElseIf pos4 = "Z" Then
         Worksheets("Long").Range("A55:I55").Select
        ElseIf pos4 = "1" And pos6 <> "C" And pos6 <> "c" Then
         Worksheets("Long").Range("A53:I55").Select
        
        'National Markets'
        ElseIf pos4 = "6" Then
         Worksheets("Long").Range("A56:I58").Select
        ElseIf pos4 = "L" And pos6 = "L" Then
         Worksheets("Long").Range("A56:I58").Select
        ElseIf pos4 = "l" And pos6 = "l" Then
         Worksheets("Long").Range("A56:I58").Select
        
        'Involuntary Markets'
        ElseIf pos6 = "S" Or pos6 = "s" Then
         Worksheets("Long").Range("A59:I61").Select
    
         
        'Liberty International Underwriters'
        'Long LIU policy numbers with beginning letters and ending with numbers'
        ElseIf numCheck13 = True And pos14 = "" And pos15 = "" Then
         Worksheets("Long").Range("A62:I64").Select
        'Short LIU that looks like SBSC numbers with an erroneous space'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And pos4 = "" And pos12 = "" Then
         Worksheets("Long").Range("A62:I64").Select
        'Short LIU that looks like SBSC numbers'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And pos11 = "" Then
         Worksheets("Long").Range("A62:I64").Select
        
        'Liberty Canada
        ElseIf pos1 = "A" Or pos1 = "a" Then
            If pos2 = "C" Or pos2 = "H" Or pos2 = "K" Or pos2 = "L" Or pos2 = "N" Or pos2 = "P" Or pos2 = "Q" Or pos2 = "R" Or pos2 = "X" Or pos2 = "Y" Or pos2 = "Z" Or pos2 = "c" Or pos2 = "k" Or pos2 = "l" Or pos2 = "n" Or pos2 = "p" Or pos2 = "q" Or pos2 = "r" Or pos2 = "x" Or pos2 = "y" Or pos2 = "z" Then
             Worksheets("Long").Range("A65:I67").Select
            End If
        ElseIf pos3 = "T" Or pos3 = "t" Or pos3 = "Q" Or pos3 = "q" Then
            If pos4 = "O" Or pos4 = "o" Or pos4 = "U" Or pos2 = "u" Then
             Worksheets("Long").Range("A65:I67").Select
            End If
       ' ElseIf pos3 = "T" And pos4 = "O" Then
       '  Worksheets("Long").Range("A65:I67").Select
       ' ElseIf pos3 = "t" And pos4 = "o" Then
       '  Worksheets("Long").Range("A65:I67").Select
       ' ElseIf pos3 = "Q" And pos4 = "U" Then
       '  Worksheets("Long").Range("A65:I67").Select
       ' ElseIf pos3 = "q" And pos4 = "u" Then
       '  Worksheets("Long").Range("A65:I67").Select
    
        'Liberty Northwest
        'LNW Containing "NC"
        ElseIf pos5 = "n" And pos6 = "c" Then
         Worksheets("Long").Range("A68:I70").Select
        ElseIf pos5 = "n" And pos6 = "C" Then
         Worksheets("Long").Range("A68:I70").Select
        ElseIf pos5 = "N" And pos6 = "c" Then
         Worksheets("Long").Range("A68:I70").Select
        ElseIf pos5 = "N" And pos6 = "C" Then
         Worksheets("Long").Range("A68:I70").Select
        'LNW Similar to SBSC
        '3 letter, a space, and 6 numbers
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And pos4 = "" And pos11 = "" Then
         Worksheets("Long").Range("A68:I70").Select
        '3 letter, 6 number'
        ElseIf letterCheck1 = True And letterCheck2 = True And letterCheck3 = True And numCheck4 = True And pos10 = "" Then
         Worksheets("Long").Range("A68:I70").Select
         
        'Liberty Life Assurance
        '8#, a space, and 2 letters and a number
        ElseIf numCheck1 = True And numCheck2 = True And numCheck3 = True And numCheck4 = True And numCheck5 = True And numCheck6 = True And numCheck7 = True And numCheck8 = True And pos9 = "" And letterCheck10 = True And letterCheck11 = True And pos12 = "3" Then
         Worksheets("Long").Range("A71:I73").Select
        '8#, 2 letters and a number
        ElseIf numCheck1 = True And numCheck2 = True And numCheck3 = True And numCheck4 = True And numCheck5 = True And numCheck6 = True And numCheck7 = True And numCheck8 = True And letterCheck9 = True And letterCheck10 = True And pos11 = "3" Then
         Worksheets("Long").Range("A71:I73").Select
        '2 letters, a number, a space, 8 numbers - ending in 3'
        ElseIf letterCheck1 = True And letterCheck2 = True And numCheck3 = True And pos4 = "" And pos13 = "3" Then
         Worksheets("Long").Range("A71:I73").Select
        '2 letters, a number, 8 numbers - ending in 3'
        ElseIf letterCheck1 = True And letterCheck2 = True And numCheck3 = True And pos13 = "3" Then
         Worksheets("Long").Range("A71:I73").Select
         
        'If what is put in does not fit any of the formatting rules
        Else
         MsgBox "You Might Be on Your Own. Review the policy formatting sheet for specialty departments. Last resort: Transfer to 800-845-4075"
        
        'End Help Button
        End If
          
    End Sub
    Last edited by JBeaucaire; 03-10-2016 at 08:32 PM. Reason: Added missing CODE tags. Please read and follow the Forum Rules, link above in the menu bar. Thanks.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to search last 4 numbers of a policy number, help.
    By Rick23 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-27-2014, 01:05 AM
  2. vba code to search last 4 numbers of a 10 digit policy number
    By Rick23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2014, 10:21 PM
  3. Replies: 2
    Last Post: 08-09-2014, 12:40 PM
  4. [HELP] Creating Lookup Tool
    By icesaiah in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-18-2013, 03:14 AM
  5. [SOLVED] Replace string with another string from another worksheet (like decode)
    By sugee in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-27-2013, 02:05 AM
  6. Replies: 2
    Last Post: 08-23-2012, 04:58 PM
  7. Replies: 1
    Last Post: 11-17-2005, 01:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1