Spaces while using "Print" in VBA

Posted by Josh on Stack Overflow See other posts from Stack Overflow or by Josh
Published on 2010-06-02T17:31:14Z Indexed on 2010/06/02 17:34 UTC
Read the original article Hit count: 348

Filed under:
|
|
|
|

For some reason I am getting a lot of spaces in front of each value while trying to print to a flat text file.

'append headers
Cells(start_row - 2, 1).Select
For i = 1 To ActiveCell.SpecialCells(xlLastCell).Column
    If ActiveCell.Offset(0, 1).Column = ActiveCell.SpecialCells(xlLastCell).Column Then
        Print #finalCSV, Cells(start_row - 2, i) & "\n",
    Else
        Print #finalCSV, Cells(start_row - 2, i) & ",",
    End If
Next i

Example output:

DC Capacity:hi,             Resistive Capacity:lo,      Resistive Capacity:hi,      Reactive Capacity:lo,

Is there any way to get rid of these spaces?

© Stack Overflow or respective owner

Related posts about beginner

Related posts about excel