Solved

use pipe as delimiter

Posted on 2014-02-18
7
475 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 81

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 81

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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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 81

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 81

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

724 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