I found a great macro on Microsoft's website to get me from an Excel 2007 file to a space delimited file, but I am having one problem. The macro is not allowing there to be no space between columns. For example, by first three columns are MEM, R, 51246. They should read MEMR51246 once the file processes however the macro is putting a space between them. It is like it is not allowing column width - text to = 0. Below is the applicable portion of the macro (I think - macro is realllllly long). If anyone can help with this or has a suggestion for an extra line to add, I would really appreciate it.
Loop through every cell, from left to right and top to bottom.
For RowNum = 1 To TotalRows
For ColNum = 1 To TotalCols
With Selection.Cells(RowNum, ColNum)
ColWidth=Application.RoundUp(.ColumnWidth, 0)
' Store the current cells contents to a variable.
Select Case .HorizontalAlignment
Case xlRight
CellText = Space(Abs(ColWidth - Len(.Text))) & .Text
Case xlCenter
CellText = Space(Abs(ColWidth - Len(.Text))/2) & .Text & _
Space(Abs(ColWidth - Len(.Text))/2)
Loop through every cell, from left to right and top to bottom.
For RowNum = 1 To TotalRows
For ColNum = 1 To TotalCols
With Selection.Cells(RowNum, ColNum)
ColWidth=Application.RoundUp(.ColumnWidth, 0)
' Store the current cells contents to a variable.
Select Case .HorizontalAlignment
Case xlRight
CellText = Space(Abs(ColWidth - Len(.Text))) & .Text
Case xlCenter
CellText = Space(Abs(ColWidth - Len(.Text))/2) & .Text & _
Space(Abs(ColWidth - Len(.Text))/2)
Case Else
CellText = .Text & Space(Abs(ColWidth - Len(.Text)))
End Select
End With
Case Else
CellText = .Text & Space(Abs(ColWidth - Len(.Text)))
End Select
End With
Loop through every cell, from left to right and top to bottom.
For RowNum = 1 To TotalRows
For ColNum = 1 To TotalCols
With Selection.Cells(RowNum, ColNum)
ColWidth=Application.RoundUp(.ColumnWidth, 0)
' Store the current cells contents to a variable.
Select Case .HorizontalAlignment
Case xlRight
CellText = Space(Abs(ColWidth - Len(.Text))) & .Text
Case xlCenter
CellText = Space(Abs(ColWidth - Len(.Text))/2) & .Text & _
Space(Abs(ColWidth - Len(.Text))/2)
Loop through every cell, from left to right and top to bottom.
For RowNum = 1 To TotalRows
For ColNum = 1 To TotalCols
With Selection.Cells(RowNum, ColNum)
ColWidth=Application.RoundUp(.ColumnWidth, 0)
' Store the current cells contents to a variable.
Select Case .HorizontalAlignment
Case xlRight
CellText = Space(Abs(ColWidth - Len(.Text))) & .Text
Case xlCenter
CellText = Space(Abs(ColWidth - Len(.Text))/2) & .Text & _
Space(Abs(ColWidth - Len(.Text))/2)
Case Else
CellText = .Text & Space(Abs(ColWidth - Len(.Text)))
End Select
End With
Case Else
CellText = .Text & Space(Abs(ColWidth - Len(.Text)))
End Select
End With