title: Excel VB - Multiple If Column Contains Strings Then
body: <p>I have looked at a bunch of questions like this, but I have only found formulas, and VB examples that don't appear to check the values of cells in a column. </p>
  
  <p>I was able to derive the following formula in Excel:</p>
  
  <pre><code>=IF(AND(ISNUMBER(SEARCH("Cat",R2)),OR(ISNUMBER(SEARCH("5E",R2)),ISNUMBER(SEARCH("6",R2))), ISNUMBER(SEARCH("Patch",R2)), ISNUMBER(SEARCH("Cables",R2))), "CAT 5E Ethernet Cables")
  </code></pre>
  
  <p>The problem is that this formula only checks for 1 out of 500 possible values. This is not productive. Plus, I have to make it one big formula when I check the entire row, because if I don't, the formula overwrites the result of the previous formula...</p>
  
  <p>So, Visual Basic... I think I may have better luck scripting some kind of <strong>IF ELSE</strong> or <strong>CASE</strong> statement. I just do not understand how to do this in excel. I need to achieve the same thing as the formula above, but instead of checking for one set of conditions, </p>
  
  <p>I need to check for multiple, and populate the <strong>S</strong> &amp; <strong>T</strong> columns based on the result of each set of conditions.</p>
  
  <p>I found this webpage that just mentions Excel and shows a VB <strong>IF - ELSE</strong> statement. How can I make this statement check Excel columns?</p>
  
  <p>I tried the selected answer in <a href="https://stackoverflow.com/questions/11527787/if-values-in-column-b-specific-text-insert-specific-text-into-a-value-in-colu">this post</a> with no luck:</p>
  
  <pre><code>    Private Sub UpdateCategories()
          Dim x As Long
          For x = 1 To 5000
              If InStr(1, Sheet1.Range("$B$" &amp; x), "cat") &gt; 0 And InStr(1, Sheet1.Range("$B$" &amp; x), "5e") &gt; 0 Then
                  Sheet1.Range("$T$" &amp; x) = Sheet1.Range("$T$" &amp; x) &amp; "CAT 5E Ethernet Cables (Test)"
              End If
          Next
      End Sub
  </code></pre>
  
  <p>Any help is appreciated. Thanks in advance!</p>