title: Excel VBA Reference variable sheet name
body: <p>I want to reference to multiple sheets in a workbook and then copy those to another workbook with vba. This is all progress of a bigger Macro I build.
  The problem I have is, that I cannot reference the sheets of the for loop with their name. May be you guys can help.
  This is an extract of my code, all names are referenced at the top of my file (like sh As worksheet, and wb as workbook)
  What my macro should do, is check sheets if they should be send to a recipient, and some of those sheets (like the code below) merged into one workbook and then send this workbook. But the problem I have is, how to delete/overwrite a specific sheet in the destination workbook. (Line 5)</p>
  
  <pre><code>For Each sh In ThisWorkbook.Worksheets
      If sh.Range("A1").Value Like "?*@?*.?*" And sh.Name &lt;&gt; "A" Or sh.Name &lt;&gt; "B" Or sh.Name &lt;&gt; "C" Then
           Workbooks.Open Filename:= _
           "Path" &amp; "Name" &amp; ".xlsx", UpdateLinks:=0
          Sheets(chr(34)&amp;sh.name&amp;chr(34)).Delete
          Set wb = ActiveWorkbook
          sh.Copy Before:=wb.Worksheets(1)
          Set wb = ActiveWorkbook
          sh.Copy Before:=wb.Worksheets(1)
          Set sc = wb.Worksheets(chr(34)&amp;sh.name&amp;chr(34))
          With sc.UsedRange
          .Value = .Value
          Rows("244:310").Select
          Selection.EntireRow.Hidden = True
          ActiveSheet.Outline.ShowLevels RowLevels:=1, ColumnLevels:=1
          Cells("B1").Select
          ActiveWindow.ScrollRow = 1
          End With
  
          Filename = "Name"
  
          Set wb = ActiveWorkbook
          Set OutMail = OutApp.CreateItem(0)
          Set OMail = OutApp.CreateItem(0)
  
          With wb
              .SaveAs FilePath &amp; Filename &amp; FileExtStr, FileFormat:=FileFormatNum
              On Error Resume Next
              With OMail
              .Display
              End With
                  signature = OMail.HTMLbody
              With OMail
                  .to = sh.Range("A1").Value
                  .CC = sh.Range("A3").Value
                  .BCC = ""
                  .Subject = Text             
                  .Attachments.Add.wb.FullName                                       
  
              End With
  
              On Error GoTo 0
  </code></pre>