title: VBA conflicting sheet name checking via an IF function
body: <p>I have two subroutines that seem to conflict one with each other. Each one of them is for creating and formatting a new worksheet if it doesn't already exist and I ran into a problem where I can only create one of them and not the other (whichever one is the first one I call to create). I found taht it seems to skip the end sub function in an if function:</p>
  <pre><code>    For Each Worksheet In Application.ActiveWorkbook.Worksheets
      Application.DisplayAlerts = False
          
      If Worksheet.Name = &quot;Machine Layout&quot; Then
      Exit Sub
      
      Else:
      Sheets.Add.Name = &quot;Machine Layout&quot;
      End If
      Next
  </code></pre>
  <p>And gives an error that sheet with such name already exists.</p>
  <p>Both subroutines use this same code except the worksheet name changes.</p>
  <p>I'm wondering what's teh problem with that? Could someone, please, help?</p>