title: Ignoring Blank Cells in CSV Export of Excel Worksheet Data
body: <p>I am trying to determine a method for 'ignoring' blank cells on a CSV file that is resulting from an Excel worksheet's data. </p>
  
  <p>The blank cell will be a result from user's input in one row OR the row below (both rows will never be filled in however, the header being referenced in a script needs to remain the same). One row pertains to one OS's disk requirements while the row below it pertains to an alternative OS's disk requirements, if applicable; the format of the disk requirements will still apply to the header in its current format.</p>
  
  <p>Currently when the VBA code is applied to the Excel worksheet, the missing data from the blank row pertaining to the first OS disk requirements 'pushes' the next row's information by inputting a blank cell. I would like to find a way to have the VBA code 'ignore' the blank row and have the proceeding row's data be input into this cell instead. The VBA code I am using:</p>
  
  <pre><code>Sub WriteCSVFile()
  
  Dim My_filenumber As Integer
  Dim logSTR As String
  
  My_filenumber = FreeFile
  
  logSTR = logSTR &amp; "Header1" &amp; " , "
  logSTR = logSTR &amp; "Header2" &amp; " , "
  logSTR = logSTR &amp; "Header3" &amp; " , "
  logSTR = logSTR &amp; "Header4" &amp; " , "
  logSTR = logSTR &amp; "Header5" &amp; " , "
  logSTR = logSTR &amp; "Header6" &amp; " , "
  logSTR = logSTR &amp; "Header7" &amp; " , "
  logSTR = logSTR &amp; "Header8" &amp; " , "
  logSTR = logSTR &amp; "Header9" &amp; " , "
  logSTR = logSTR &amp; "Header10" &amp; " , "
  logSTR = logSTR &amp; "Header11" &amp; " , "
  logSTR = logSTR &amp; "Header12" &amp; " , "
  logSTR = logSTR &amp; "Header13" &amp; " , "
  logSTR = logSTR &amp; Chr(13)
  logSTR = logSTR &amp; Cells(18, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(19, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(20, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(21, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(22, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(26, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(27, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(28, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(29, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(30, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(31, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(32, "C").Value &amp; " , "
  </code></pre>
  
  <p>If there is no data resulting from logSTR = logSTR &amp; Cells(31, "C").Value &amp; " , " I would like to have the data from logSTR = logSTR &amp; Cells(32, "C").Value &amp; " , " placed in that cell rather than leaving a blank. This would allow the data's format (3 values separated by a comma) line up with Header11, Header12 and Header13 (and not Header12, Header13 and No Header).</p>
  
  <pre><code>logSTR = logSTR &amp; Chr(13)
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; Cells(36, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(37, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(38, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(39, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(40, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(41, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(42, "C").Value &amp; " , "
  logSTR = logSTR &amp; Chr(13)
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; "" &amp; " , "
  logSTR = logSTR &amp; Cells(46, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(47, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(48, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(49, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(50, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(51, "C").Value &amp; " , "
  logSTR = logSTR &amp; Cells(52, "C").Value &amp; " , "
  
  Open "Z:\SHARED DRIVE\RequestDirectory\" &amp; ThisWorkbook.Name &amp; ".csv" For Append As #My_filenumber
      Print #My_filenumber, logSTR
  Close #My_filenumber
  
  
  End Sub 
  </code></pre>