Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export a range of data in excel to ascii plain text formatted table csv or txt file using vba

I need to export only a range of data from Excel or LibreOffice Calc file to ascii plain text table - text file. The output should be in the format as follows :

+--------+--------------+--------+
| Name   | Place        | Phone  |
+========+==============+========+
| JOHN   | TEXAS        | 123456 |
+--------+--------------+--------+
| ROBERT | INDIANAPOLIS | 234567 |
+--------+--------------+--------+
| JEANNE | CAMBODIA     | 345678 |
+--------+--------------+--------+
| ANN    | CANADA       | 456789 |
+--------+--------------+--------+
| RICK   | HAGUE        | 567890 |
+--------+--------------+--------+

Is it possible using vba ? And yes, the numbers should be Right aligned.

Or like this :

+--------+--------------+--------+
| Name   | Place        | Phone  |
+========+==============+========+
| JOHN   | TEXAS        | 123456 |
| ROBERT | INDIANAPOLIS | 234567 |
| JEANNE | CAMBODIA     | 345678 |
| ANN    | CANADA       | 456789 |
| RICK   | HAGUE        | 567890 |
+--------+--------------+--------+
like image 374
adam1969in Avatar asked Nov 15 '25 06:11

adam1969in


1 Answers

If I'm not mistaken, a plain text file won't justify a column at all.

That said, give this a try: http://www.excel-easy.com/vba/examples/write-data-to-text-file.html

like image 152
thedatadavis Avatar answered Nov 17 '25 21:11

thedatadavis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!