Excel export delimited text macro

Export Tab-delimited text from Excel

Posted on Friday, April 30th, 2010 at 12:05 pm

I often need to save text from Excel to use with PHP, but I find Excel’s “Save As” functionality less that useful, as it converts your open worksheet to a text, which is a real pain.

This macro exports the current worksheet as a tab-delimited or comma-delimited text file, with the following features:

  • optionally exports the current selection
  • outputs values as text
  • strips leading and trailing whitespace
  • quotes any cells with spaces (TSV only)
  • warns if the file is locked

Here’s an example of the two file outputs:

Tab-separated values

id      word    words
1       hello   "hello there"
2       goodbye "goodbye then"
3       a       "a, b, c"

Comma-separated values

id,word,words
1,hello,hello there
2,goodbye,goodby then
3,a,a, b, c

Download ExportDelimitedText

2 Responses to “Excel export delimited text macro”

  1. alle |

    I recently found this, I don’t know if it could be helpful to you:

  2. Dave Stewart |

    For my current app, I just need CSV files, but this is a great find! Thanks :)

Make a comment or suggestion...