Create a TXT file from contents in a XLSM file

VJ1985

New Member
Joined
Aug 1, 2013
Messages
8
Hi Guys,

I'm new to Excel with regards to Macros/VBA and hence need help to create a TXT file from the contents in a XLSM file.

The user enters the information in an XLSM file as follows:

[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD="align: center"]Company Name:[/TD]
[TD="align: center"]CarSalesPtyLtd[/TD]
[TD="align: center"][/TD]
[TD="align: center"]Code:[/TD]
[TD="align: center"]CSPL04[/TD]
[/TR]
[TR]
[TD="align: center"]VEHICLE NUMBER[/TD]
[TD="align: center"]MAKE[/TD]
[TD="align: center"]MODEL[/TD]
[TD="align: center"]YEAR[/TD]
[TD="align: center"]COLOUR[/TD]
[/TR]
[TR]
[TD]ABC123[/TD]
[TD]TOYOTA[/TD]
[TD]HILUX[/TD]
[TD]2000[/TD]
[TD]WHITE[/TD]
[/TR]
[TR]
[TD]DEF456[/TD]
[TD]FORD[/TD]
[TD]FOCUS[/TD]
[TD]1998[/TD]
[TD]RED[/TD]
[/TR]
[TR]
[TD]GHI789[/TD]
[TD]MERCEDES[/TD]
[TD]SLK GTR[/TD]
[TD]2011[/TD]
[TD]GREY[/TD]
[/TR]
[TR]
[TD]JKL012[/TD]
[TD]TOYOTA[/TD]
[TD]CAMRY[/TD]
[TD]2013[/TD]
[TD]BLACK[/TD]
[/TR]
[TR]
[TD]PQR678[/TD]
[TD]NISSAN[/TD]
[TD]SKYLINE[/TD]
[TD]1999[/TD]
[TD]WHITE[/TD]
[/TR]
</tbody>[/TABLE]












Once done, the user clicks on a button which should create a TXT file as follows:
CarSalesPtyLtd
CSPL04​
YYYYMMDDHHMMSS Start
Vehicle, 1, ABC123, TOYOTA, HILUX, 2000, WHITE
Vehicle, 2, DEF456, FORD, FOCUS, 1998, RED
Vehicle, 3, GHI789, MERCEDES, SLK GTR, 2011, GREY
Vehicle, 4, JKL012, TOYOTA, CAMRY, 2013, BLACK
Vehicle, 5, PQR678, NISSAN, SKYLINE, 1999, WHITE
CarSales​
PtyLtd
CSPL04​
YYYYMMDDHHMMSS End




Also, once the user clicks the button, is it possible to save the TXT file with a filename from the cell contents, but prompt the user for the save location?

For instance, save the above TXT file as "
CarSalesPtyLtd-CSPL04.TXT"
Many thanks in advance!
Cheers,
VJ​
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Not sure why the above text is aligned like that... looked fine in the editor!

Anyway, this how the TXT file should appear:

CarSalesPtyLtd, CSPL04, YYYYMMDDHHMMSS, Start
Vehicle, 1, ABC123, TOYOTA, HILUX, 2000, WHITE
Vehicle, 2, DEF456, FORD, FOCUS, 1998, RED
Vehicle, 3, GHI789, MERCEDES, SLK GTR, 2011, GREY
Vehicle, 4, JKL012, TOYOTA, CAMRY, 2013, BLACK
Vehicle, 5, PQR678, NISSAN, SKYLINE, 1999, WHITE
CarSalesPtyLtd, CSPL04, YYYYMMDDHHMMSS, End

Thanks again!
VJ
 
Upvote 0

Forum statistics

Threads
1,223,237
Messages
6,170,924
Members
452,366
Latest member
TePunaBloke

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