title: IF Column AJ contains "Customer" then Apply Filter in B:B Else In VBA
body: <p>I have written a small script in VBA. Say I have the data in Excel worksheet (<code>sheet1</code>) and want to apply filter on certain condition. If column <code>AJ:AJ</code> contains the word "CUSTOMER", then apply filter range <code>B:B</code> or <code>Else Msgbox("Customer NA")</code>. I am currently using the code below, but it is making the Excel freeze. Any help really appreciated.</p>
  
  <pre><code>Sub test()
      For i = 1 To 1048576
          Range("AJ" &amp; i).Select
          ss = Len(ActiveCell.Value)
          For j = 1 To ss
              dd = StrConv(Mid(ActiveCell.Value, j, 8), vbProperCase)
              If dd = "Customer" Then
                  check = 1
                  check = 0
                  Range("AJ1").Activate
                  Selection.AutoFilter
                  Selection.End(xlToRight).Select
                  Range("AJ1").Select
                  ActiveSheet.Range("$A$1:$AQ$37518").AutoFilter Field:=36, Criteria1:= _
                      "=*Customer*", Operator:=xlAnd
                  Exit For
                  check = 0
              Else
              End If
          Next j
          If check = 1 Then
              Exit For
          Else
          End If
      Next i
  End Sub
  </code></pre>