title: VBA Function never return to main Sub
body: <p>I'm trying to figure this out. In my main sub, I call a function. Somehow it ended my run at the end of that function. It displays "Before end" and never displays "I made it out" Does anybody know what the problem is? </p>
  
  <pre><code>Sub Main()
        call CopyAndDelete()
        msgbox "I made it out"
  End Sub
  
  Function CopyAndDelete()
  Dim CopyFromWB As Workbook
  Dim CopyToWB As Workbook
  Dim wb As Workbook
  Dim CopyThisWS As Worksheet
  Dim ws As Worksheet
  Dim Path As String
  Dim FileName As String
  
  Application.DisplayAlerts = False
  
  Set CopyToWB = Workbooks("test.xlsm")
  CopyToWB.Activate
  
  For Each ws In ActiveWorkbook.Sheets
      Select Case ws.Name
          Case "A"
              ws.Delete
          Case "B"
              ws.Delete
          Case "C"
              ws.Delete
          Case "D"
              ws.Delete
      End Select
  Next ws
  
  Path = Application.GetOpenFilename(Title:="choose a file")
  FileName = Right(Path, Len(Path) - InStrRev(Path, "\"))
  For Each wb In Workbooks
      If wb.Name = FileName Then
          Workbooks(FileName).Close
      End If
  Next wb
  
  Set CopyFromWB = Workbooks.Open(Path)
  Set CopyThisWS = CopyFromWB.Worksheets(1)
  CopyThisWS.Copy After:=CopyToWB.Worksheets(1)
  ActiveSheet.Name = "New A"
  CopyFromWB.Close
  
  Application.DisplayAlerts = True
  
  MsgBox "Before end"
  
  End Function
  </code></pre>