title: Have an Excel macro skip lines if a cell is blank
body: <p>I'm nearing the end of this macro I'm developing for the processing of text reports, but I'm not sure how to ignore when the reports I'm pulling in are blank.</p>
  
  <p>What occurs is that the text file is pulled in, and while there is some data in the text file, it's not relevant to what I need to extract. I've identified that <code>Sheet1.Range("A5")</code> will be blank if the report is blank for my purposes, but I'm not sure how to tell the macro to skip the steps where I've left the comment "Copy values to main data table".</p>
  
  <p>Effectively, I want to go through the process all the way up to that comment, and then I need for the macro to look at <code>Sheet1.Range("A5")</code>. If it's blank, then I want it to skip ahead to the <code>Sheet6.Activate</code> line and carry on executing.</p>
  
  <p>Do I just put an If statement before the copy?</p>
  
  <pre><code>Sub Import()
  
      Application.ScreenUpdating = False
      Application.DisplayAlerts = False
  
  ' Variables for paths and filename
  
  Dim currentPath As String
  Dim newPath As String
  Dim currentFile As String
  
  currentPath = "\\Unprocessed\"
  newPath = "\\Processed\"
  
  ' Get the first file
  
      currentFile = Dir(currentPath &amp; "*.txt")
      Do While currentFile &lt;&gt; ""
  
  ' Clear previous data
  
      Sheet1.Activate
      ActiveSheet.UsedRange.Clear
      Range("A1").Select
  
  ' Process text file
  
      With ActiveSheet.QueryTables.Add(Connection:= _
          "TEXT;" &amp; currentPath &amp; currentFile, _
          Destination:=Range("$A$1"))
          .Name = "Data"
          .FieldNames = True
          .TextFileTabDelimiter = True
          .TextFileColumnDataTypes = Array(3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)
          .Refresh BackgroundQuery:=False
      End With
  
      ActiveSheet.QueryTables(1).Delete
  
  ' Copy values to main data table
  
      Sheet3.Range("A2:Q2").Copy
      Sheet6.Range("A" &amp; Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
      Sheet6.Activate
  
  ' Move file into Processed folder
  
      Name currentPath &amp; currentFile As newPath &amp; currentFile
  
  ' Get the next file
  
      currentFile = Dir
      Loop
  
      Application.ScreenUpdating = True
      Application.DisplayAlerts = True
  
  End Sub
  </code></pre>