Results 1 to 4 of 4

Modify a Function to add an extra condition

Threaded View

  1. #1
    Registered User
    Join Date
    09-11-2008
    Location
    Ottawa
    Posts
    42

    Modify a Function to add an extra condition

    Hi,

    I want to modify the function in the code below to test 2 variables instead of just the 1.

    So, as an example, in the first IF statement, the string looks for "CAMP MIRAGE BASED UNITS/TACTICAL AIRLIFT UNIT" and if found it returns "A - CM - TAU".

    I would like this IF statement to look for "CAMP MIRAGE BASED UNITS/TACTICAL AIRLIFT UNIT" and a date in the same row (column N) (example 02 Sep 2009) before giving it's return.


    Function findCode(strIn As String) As String
    
    
        If InStr(strIn, "CAMP MIRAGE BASED UNITS/TACTICAL AIRLIFT UNIT") > 0 Then
        findCode = "A – CM – TAU"
        Exit Function
        End If
    
        If InStr(strIn, "CAMP MIRAGE BASED UNITS/THEATRE SUPPORT ELEMENT") > 0 Then
            findCode = "B – CM TSE"
        Exit Function
        End If
    
        If InStr(strIn, "KABUL and OTHER LOCATION UNITS/MISC HQ and STAFFS") > 0 Then
            findCode = "C – MISC HQ & STAFF"
        Exit Function
        End If
    
        If InStr(strIn, "KABUL and OTHER LOCATION UNITS/SLTC – A") > 0 Then
            findCode = "Nothins specified"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/ASIC") > 0 Then
            findCode = "D – ASIC"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/AVN COY") > 0 Then
            findCode = "Nothins specified"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/ENGR SUPPORT UNIT") > 0 Then
            findCode = "E – ENGR SP"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/HSS UNIT") > 0 Then
            findCode = "F – HSS"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/INF BG") > 0 Then
            findCode = "G – INF BG"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/JTF AFG HQ") > 0 Then
            findCode = "H – JTF AFG HQ BLK 1"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/MP COY") > 0 Then
            findCode = "I – MP COY"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/NSE") > 0 Then
            findCode = "J – NSE"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/OMLT") > 0 Then
            findCode = "K – OMLT"
        Exit Function
        End If
    
        If InStr(strIn, "KANDAHAR BASED UNITS/PRT") > 0 Then
            findCode = "L – PRT"
        Else
            findCode = "No Code Specified"
        End If
    
        
    End Function

    Thank You

    TB
    Last edited by King_Quake; 10-03-2008 at 10:32 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. function to extra data from cells
    By memphis0607 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-03-2008, 12:02 PM
  2. Function recognizes two columns and adds total of two other columns
    By grafx77 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 07-18-2007, 09:09 AM
  3. Analysis Toolpak Function XIRR and VBA - XL 2007
    By rvExcelNewTip in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2007, 04:35 AM
  4. Exit Function doesn't break out of For loop?
    By odeno in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2007, 11:51 AM
  5. Function and Personal.xls
    By boylejob in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2007, 12:32 PM

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