Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 505
  • Last Modified:

use pipe as delimiter

I need a way to export some data from either google spreadsheets or excel.  The catch is i need to use a pipe | as a delimiter.  I do not want to have to change my region settings in windows each time to do this.  Im hoping someone can point me to either an excel macro or google spreadsheet script that will do this.
0
colonialiu20
Asked:
colonialiu20
  • 4
  • 3
1 Solution
 
byundtCommented:
Microsoft Excel MVP Chip Pearson gives code to save some data as a text file using a user-specified delimiter at http://www.cpearson.com/excel/ImpText.aspx "Exporting And Import Text With Excel"

You would use Mr. Pearson's ExportToTextFile sub with a macro like this:
Sub DoTheExport() 
     ExportToTextFile FName:="C:\Test.txt", Sep:="|", _
        SelectionOnly:=False, AppendData:=False
 End Sub

Open in new window

0
 
colonialiu20Author Commented:
That does not appear to be working.  see attachment.  I can't get it to generate a file.
pipe.xls
0
 
byundtCommented:
I changed the code to this:
Sub DoTheExport()
ExportToTextFile FName:="X:\VBA\Sample '14\Test.txt", Sep:="|", _
       SelectionOnly:=False, AppendData:=False
End Sub

Open in new window

And got the following results:
Sample results
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
colonialiu20Author Commented:
I'm running this on a mac.  any difference?  see my attached spreadsheet.  when i run the macro, i do not get any errors, yet nothing appears in my directory.
pipe.xls
0
 
byundtCommented:
You need to write the path correctly to use the code on a Mac. The path separator is a colon instead of slash.

The following code is producing the same result as previously posted when I ran this sub using Excel 2011 (Mac):
Sub DoTheExport()
ExportToTextFile FName:="MacSSD512:Users:byundt:Desktop:Old HP drive:VBA:Sample '14:Test.txt", Sep:="|", _
       SelectionOnly:=False, AppendData:=False
End Sub

Open in new window


I put the following statement in the Immediate pane to get the path of the .xls workbook:
?ActiveWorkbook.FullName

After typing the above statement, hit Enter. You should see the path in the very next line of the Immediate pane. I copied that path (deleting the file name of course) into the code.

Brad
0
 
byundtCommented:
colonialiu20,
For future reference, it is always a good idea to post the version of Excel that you are using when asking a question in a forum. This is especially true if you are using a Mac.

You can put the Excel version in the question title, question body or question tags. The more common approach at Experts Exchange is to use the tags.

Brad
0
 
colonialiu20Author Commented:
very responsive!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now