?
Solved

use pipe as delimiter

Posted on 2014-02-18
7
Medium Priority
?
488 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
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.

 

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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
Many of you may be aware of the recent Google Docs scam emails that have been floating around coming from various people that you know. Here's a guide on identifying How To Identify the Scam Email You will see an email from someone you’ve had co…
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 the scrolling table in Microsoft Excel using the INDEX function.

765 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