Saving from excel to fixed width file

pmsteph

New Member
Joined
Oct 17, 2003
Messages
33
I need to save/copy data I have set up in Excel into a fixed width file for importing into a database.

Is this possible & how do I set it up so the columns are the correct widths?

Any help would be useful.
 

Some videos you may like

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
We could certainly automate this with VBA; and perhaps someone with time to do it will stop by. But in the meantime, here's a simply way to get you going.
  1. Create a row with your required widths. (Row 1 in my example.)
  2. Create a formula that concatenates the columns together, using the LEN() and REPT() functions to pad appropriately.
  3. Then you can copy the contents of your composite column over to NOTEPAD, paste in and save and your done.
book1
ABCDEF
15101081Composite
2aaBBBBBCCCCCCCDDDDDDZaa BBBBB CCCCCCC DDDDDD Z
3aBBCCCCCDZa BB CCCCC D Z
4AAAAbbbbbbbCcCcddddZAAAA bbbbbbb CcCc dddd Z
Sheet1


Formula in F2 and downwards: <ul>[*]=A2&REPT(" ",A$1-LEN(A2))&B2&REPT(" ",B$1-LEN(B2))&C2&REPT(" ",C$1-LEN(C2))&D2&REPT(" ",D$1-LEN(D2))&E2&REPT(" ",E$1-LEN(E2))[/list]

HTH
 

Greg Truby

MrExcel MVP
Joined
Jun 19, 2002
Messages
10,014
OK - this does actually work -- the problem is that the PHP software of this board strips out double spaces. So don't worry that column F doesn't look right in the posted example.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,975
Messages
5,599,127
Members
414,291
Latest member
yanqing06

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
Top