title: VBA Code to Copy Non Blank Cells From one Sheet to Another
body: <p>I'm trying to write a VBA code to copy "Non-Blank" cells from one file to another. This code selects the last Non Blank row, but for the column it's copying <code>A4 to AU</code>. I'd like to copy columns <code>A4 to LastcolumnNotblank</code> and also last row. So basically copy <code>A4 to (LastColumn)(LastRow)Not Blank</code></p>
  
  <p>Would be really grateful if someone can help by editing the below code. Many thanks. </p>
  
  <pre><code>Sub Export_Template()
  
  '' TPD
  
  File_name = Application.GetSaveAsFilename(InitialFileName:="Engineering TPD", FileFilter:="Excel Files (*.xlsx), *.xlsx")
  
  If File_name &lt;&gt; False Then
  
   Application.ScreenUpdating = False
   Application.DisplayAlerts = False
  
   LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
  
   For i = 4 To LastRow
   If Left(ActiveSheet.Range("A" &amp; i).Value, 1) &lt;&gt; "" Then lastactiverow = i
   Next i
     'MsgBox (lastactiverow)
      ActiveSheet.Range("A4:AU" &amp; lastactiverow).Select
      Selection.Copy
  
  Set NewBook = Workbooks.Add
  
  ActiveSheet.Range("A1").PasteSpecial xlPasteValues
  
      ActiveWorkbook.SaveAs Filename:=File_name, FileFormat:=51
  
      ActiveWorkbook.Close (False)
  
  End If
  End Sub
  </code></pre>