ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   embed alignment in csv file (https://www.excelbanter.com/excel-discussion-misc-queries/151760-embed-alignment-csv-file.html)

Abbey Normal

embed alignment in csv file
 
Does anyone know if there is a way to embed the alignment in a csv file so
that it aligns correctly when I open it in excel?
For instance If I create a csv file with '""01234""' the column will open as
an text field. I was hoping to do something like the same with aligning left
or right.
THank you,

Stephane Quenson

embed alignment in csv file
 
A CSV file only contains data, no formatting information. Excel will use the
general format for each column (texts are aligned left, numbers are aligned
right). What you could do is to have the first row of your file with the
alignment you need for each column, then run a short macro that would perform
alignment according to the instructions.

Sub AlignColumns()
' Align columns according to the text
' "left", "right", "center" in the first row

Dim i As Long

For i = 1 To 255
Select Case LCase(Cells(1, i))
Case "left"
Columns(i).HorizontalAlignment = xlLeft
Case "right"
Columns(i).HorizontalAlignment = xlRight
Case "center"
Columns(i).HorizontalAlignment = xlCenter
End Select
Next i

End Sub


challa prabhu

embed alignment in csv file
 
No.

It is not possible.

Challa Prabhu

"Abbey Normal" wrote:

Does anyone know if there is a way to embed the alignment in a csv file so
that it aligns correctly when I open it in excel?
For instance If I create a csv file with '""01234""' the column will open as
an text field. I was hoping to do something like the same with aligning left
or right.
THank you,


Abbey Normal

embed alignment in csv file
 
ok, thanks for the reply.

"challa prabhu" wrote:

No.

It is not possible.

Challa Prabhu

"Abbey Normal" wrote:

Does anyone know if there is a way to embed the alignment in a csv file so
that it aligns correctly when I open it in excel?
For instance If I create a csv file with '""01234""' the column will open as
an text field. I was hoping to do something like the same with aligning left
or right.
THank you,



All times are GMT +1. The time now is 10:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com