Results 1 to 26 of 26

If statement check

Threaded View

  1. #1
    Registered User
    Join Date
    12-03-2008
    Location
    Chicago
    Posts
    13

    If statement check

    I would like this code to check if there is already something in the cell, and if so, add a comma and space, then output the next appropriate condition of the if statement. The way I have the code written currently, it checks one column to see if a word exists, then if so, it outputs a word associated with this condition. Under this method, the code does not take account for columns that have more than one matching word. I've included a small portion of the code, there are more elseif statements, but they are redundant for this purpose. Thanks in advance for your help!!!

    Sub Industry()
    
    'Change this to reflect your true starting row.
    vStartRow = 8
    
    For i = vStartRow To Cells(Rows.Count, "M").End(xlUp).Row
    
    'ITE
        If InStr(1, Range("M" & i).Value, "UL 60950") Or InStr(1, Range("M" & i).Value, "UL 60950-1") _
            Or InStr(1, Range("M" & i).Value, "UL 1459") Or InStr(1, Range("M" & i).Value, "UL 497") _
            Or InStr(1, Range("M" & i).Value, "UL 497A") Or InStr(1, Range("M" & i).Value, "UL 497B") _
            Or InStr(1, Range("M" & i).Value, "UL 497C") Or InStr(1, Range("M" & i).Value, "UL 1863") _
            Or InStr(1, Range("M" & i).Value, "UL 1310") Or InStr(1, Range("M" & i).Value, "UL 1012") _
            Or InStr(1, Range("M" & i).Value, "UL 61965") Or InStr(1, Range("M" & i).Value, "UL 60601-1") _
            Or InStr(1, Range("M" & i).Value, "UL 60601A-1") Or InStr(1, Range("M" & i).Value, "UL 60601B-1") _
            Or InStr(1, Range("M" & i).Value, "UL 60601C-1") Or InStr(1, Range("M" & i).Value, "UL 1863") Then
                Range("N" & i).Value = "ITE"
    
    'Insulating Materials
        ElseIf InStr(1, Range("M" & i).Value, "UL 94") Or InStr(1, Range("M" & i).Value, "UL 840") _
            Or InStr(1, Range("M" & i).Value, "UL 1446") Or InStr(1, Range("M" & i).Value, "UL 2353") _
            Or InStr(1, Range("M" & i).Value, "UL 1692") Or InStr(1, Range("M" & i).Value, "UL 224") _
            Or InStr(1, Range("M" & i).Value, "UL 1441") Or InStr(1, Range("M" & i).Value, "UL 1696") _
            Or InStr(1, Range("M" & i).Value, "UL 969") Then
                Range("N" & i).Value = "Insulating Materials"
    
    End If
    Next i
    
    End Sub
    Last edited by VBA Noob; 12-03-2008 at 02:50 PM.

Thread Information

Users Browsing this Thread

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

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