title: Excel VBA - How to add multiple statements in If Then - If (Condition 1) Then (Close window) and (End Sub)
body: <p>I have created a macro where it copies certain cells and pastes it in a new window(Excel). I am trying to add an If Then statement in the Macro where after pasting the data, if a particular cell is blank (lets say A2), I want the macro to close that window and end the Macro. I have tried the below coding but it gives me <strong><em>Compile Error: Block if without End IF</em></strong>. </p>
  
  <pre><code>Windows("Data.xlsx").Activate
  Rows("13:18").Select
  Selection.Copy
  Windows("Data Paste.xlsx").Activate
  
  Range("A1").Select
  ActiveSheet.Paste
  
  
  If ActiveSheet.Range("A2").Value = "" Then
  ActiveWindow.Close
  End Sub
  End If
  
  Range("A2:A6").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  
  End Sub
  </code></pre>
  
  <p>Just to be more clear, what i need is; first Rows 13:18 to be copied from "DATA.xlsx" and pasted in "Data Paste.xlsx" and then to check if the Cell A2 is empty and if so to close window "Data Paste.xlsx" and stop the Macro from Running. If the A2 cell is not empty I want the Macro to continue without closing the window and continue with the bellow code: </p>
  
  <pre><code>Range("A2:A6").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  'Rest of the code
  </code></pre>
  
  <p>Please find me a solution. </p>