Export to Notepad but keeping blank spaces in the cell?

compact

New Member
Joined
Jun 27, 2007
Messages
26
Hi

I have to export 6 columns of data to notepad, to feed into another system.
All ok, but I have to ensure that each entry in the column is made up of 16 characters, using spaces where there are no words.
i.e.
In Excel
qwerty qwew qqqq
hi hello heellllllo

In Notepad
qwerty qwew qqqq
hi hello heelllllo


This way the batch program can read the columns in the txt file.

Any ideas?
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
So you simply need to pad each line of data. Correct? Does the notepad file need to be saved or does this "other" program read directly from a currently opened file.
 
Upvote 0
I have been having lots of 'fun' with this, this morning.
Excel is very annoying.

I am taking addresses from a spreasheet, into a flat file to be run as a batch, to import to them.
The format the 'other' program needs is.
35 chars, 35 chars, 15 chars, 15 chars, 15 chars, 15 chars, 8 chars,

So this has nearly worked,

=A1&REPT(" ",35-LEN(A1)) & B1&REPT(" ",35-LEN(B1)) & C1&REPT(" ",15-LEN(C1)) etc

BUT
It doesn't like it if the first column is blank,
If a number is the first character in a cell.

and sometimes if just brings back #Value for no reason at all.
Excel is very temperamental indeed..
 
Upvote 0
Maybe

=A1&REPT(" ",15-LEN(A1)) & B1&REPT(" ",15-LEN(B1)) & C1&REPT(" ",15-LEN(C1))

So you get it all in one cell.
Then copy and paste special Value onto 2nd sheet, then save to txt file.

VBA Noob
 
Upvote 0
that's just what i put, but you reduced the 35's to 15's.

It wasn't excel anyway.

I had some text in a column, that was larger than 15 chars, so it didn't like it...
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,850
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top