title: Using Like operator to work through different workbooks
body: <p>I have two different workbooks that will be generated and kept open. The names have either "outbound" or "inbound" and then the date and time. E.g "data-details-outbound 2019-03-07..." and "data-details-inbound 2019-03-07...". I need different code to be performed on each worksheet, so I need my code to differentiate between the two. </p>
  
  <p>I have the following code, but when I run it it just does all the actions on whatever workbook is activated.</p>
  
  <pre><code>Sub NotifiedReminderEmail()
  '
  ' Current issue is the LIKE operator is choosing whatever wb is open, not the correct one.
  '
      Dim wb As Workbook
      Dim owbName As String
      Dim iwbName As String
  
      owbName = "outbound"
      iwbName = "inbound"
  
      'sets up the OB sheet
      For Each wb In Application.Workbooks
          If wb.Name Like "*" &amp; owbName &amp; "*" Then
              Debug.Print wb.Name
              With wb.Worksheets(1)
                  'perform code
              End With
          End If
      Next wb
  
      'sets up the IB sheet
      For Each wb In Application.Workbooks
          If wb.Name Like "*" &amp; iwbName &amp; "*" Then
              Debug.Print wb.Name
              With wb.Worksheets(1)
                  'perform code
              End With
          End If
      Next wb
  
  End Sub
  </code></pre>