Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I export data in text format with minimum of spaces?

If you save as a .prn file, excel will use the column widths to pad (or
truncate!) the values.

Maybe you could adjust the columnwidths to be what you want before you save.
I'd change the font to Courier New (a non-proportional font) to make it a bit
easier.

You may be able to use a formula in a helper cell in each row:

=left(a1,3) & " " & text(b1,"00" & " " & ....

Then copy that formula down the column (after you have it perfekt!). Then copy
that column, paste into Notepad and save from there.

You could hide that column so that it's always available, but not too
distracting.

====
Or you could use a macro and write code and have complete control over what you
write.

Here are three sites that you could steal some code from:

Earl Kiosterud's Text Write program:
www.smokeylake.com/excel
(or directly: http://www.smokeylake.com/excel/text_write_program.htm)

Chip Pearson's:
http://www.cpearson.com/excel/imptext.htm

J.E. McGimpsey's:
http://www.mcgimpsey.com/excel/textfiles.html

==============
Take a look at Earl's program. It may do what you want.



wrote:

The following macro exports a specified portion of Excel file as
a .prn:

Sub ExportA1()

Sheets("A1").Select
ActiveWindow.SmallScroll Down:=-3
Range("D321:AR350").Select
Selection.Copy
Sheets.Add
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:= _
"Detail.prn", FileFormat:=xlTextPrinter, CreateBackup:=False
End Sub

The output looks more or less like this:

SKU 01 0 570511455 2 1
2.49 2.49
SKU 01 0 570511455 2 1
14.99 -1.50 13.49

Whereas I want it to look like this:

SKU 01 0 570511455 2 1 2.49 2.49
SKU 01 0 570511455 2 1 14.99 -1.50 13.49

Does SaveAs have a parameter which would compress any sequence of
spaces into one space?


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom Format alphanumberic value with spaces Bruce Excel Worksheet Functions 2 November 28th 05 12:04 PM
Can I retrieve a value and its format using the minimum function? daled Excel Worksheet Functions 1 November 2nd 05 09:38 PM
Conditional format of minimum number MaggieMagill Excel Worksheet Functions 6 September 25th 05 11:36 PM
Can Excel Export Data to Word Format? Reddiance Excel Discussion (Misc queries) 2 April 18th 05 06:03 PM
Empty Cells, Spaces, Cond Format? Ken Excel Discussion (Misc queries) 3 December 4th 04 04:47 PM


All times are GMT +1. The time now is 08:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"