title: Loop through worksheets with a specific name
body: <p>Say I have 10 worksheets and 4 have very similar names: </p>
  
  <blockquote>
    <p>1.danger tom<br>
    2.danger man<br>
    3.danger ten<br>
    4.danger lan  </p>
  </blockquote>
  
  <p>I want my code to find all worksheets with the text string <em>danger</em> in its name and execute my code</p>
  
  <p>I've tried the following two instances:</p>
  
  <pre><code>Public Sub SubName()
  
  Dim ws As Worksheet
  
  For Each ws In ActiveWorkbook.Worksheets
  
      If ws.Name Like "danger" Then
         *Also tried this version: If ws.Name Like "danger" = True Then*
  
          Range("A1").Interior.ColorIndex = 37
      End If
  
  Next ws
  
  End Sub 
  </code></pre>
  
  <p><em>take 2</em></p>
  
  <pre><code>Sub WorksheetLoop()
  
  Dim ws  As Worksheet
  
  For Each ws In ActiveWorkbook.Worksheets
      If InStr("danger", ws.Name) &gt; 0 Then
          Range("A1").Interior.ColorIndex = 37
      End If
  Next ws
  
  End Sub
  </code></pre>
  
  <p>The first code doesn't do anything, even though there's no errors. The second code only does something if the name matches exactly with what I wrote down.</p>
  
  <p>Any help is needed.</p>