Solved

use pipe as delimiter

Posted on 2014-02-18
7
457 Views
Last Modified: 2015-03-02
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
Comment
Question by:colonialiu20
  • 4
  • 3
7 Comments
 
LVL 80

Expert Comment

by:byundt
ID: 39869168
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
 

Author Comment

by:colonialiu20
ID: 39869240
That does not appear to be working.  see attachment.  I can't get it to generate a file.
pipe.xls
0
 
LVL 80

Expert Comment

by:byundt
ID: 39869246
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:colonialiu20
ID: 39869256
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
 
LVL 80

Accepted Solution

by:
byundt earned 500 total points
ID: 39869303
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
 
LVL 80

Expert Comment

by:byundt
ID: 39869308
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
 

Author Closing Comment

by:colonialiu20
ID: 39869333
very responsive!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many add-ons for Google docs, slides and sheets that can be extremely helpful in keeping your files organized and simple to use. Add-ons are installed into your Google docs, slides or sheets through Google's Add-On Store. One of my favorit…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate Google Calendar to monitor updates with top sites, such as Facebook, Google, Twitter, etc. with Marketing News. Each update of Google Calendar can be monitored, correlate dips and spikes in your website traffic, …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now