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:
id word words 1 hello "hello there" 2 goodbye "goodbye then" 3 a "a, b, c"
id,word,words 1,hello,hello there 2,goodbye,goodby then 3,a,a, b, c