Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Force a number to be text in a CSV

4,177 views
Skip to first unread message

Richard Lister

unread,
Jul 24, 2001, 5:43:10 AM7/24/01
to
Hi,
I need to create a CSV file in another app then bring in into Excel
with a simple double click on the file. Some of the data is what we
call ledger codes - not numbers -ie 0204, 0206 , 2234.
Trouble is CSV interprets them as numbers and we get 204, 206, 2234.

Does anyone know of a way to force certain fields into text format
within a CSV file?
thanks,
Richard

Please remove my email address when spamming.

Peo Sjoblom

unread,
Jul 24, 2001, 6:34:55 AM7/24/01
to
You can use the "text import wizard" (xl2000 and forward) and in step 3
select "Text", I just tested your codes and they come out as text with the
leading zeros... In fact the "wizard" automatically opened regardless of
whether I chose "Data>Import External Data or just opened it using the File
menu (using xl 2002 on this computer).. If I choose "General" in step 3,
they come out as numbers...

--
Regards,

Peo Sjoblom


"Richard Lister" <richard...@calderdale.gov.uk> wrote in message
news:4fef7bad.01072...@posting.google.com...

Roland M.

unread,
Jul 24, 2001, 6:47:42 AM7/24/01
to
Hi Richard,

Sorry this isn't the double click. Maybe you know this already to get a csv
with the 0206 fields intact into Excel.

Go to mainmenu... Data/Get external Data/ Import Text file
Then click the all files option and find your csv file. Importing it this
way allows the 0206, fields to remain intact. Also you could just save the
file as a txt file and open that directly in Excel.

You could create a macro using the macro recorder to do either of these
import tasks and parse the data for you.

--
Sincerely,
Roland M
Rolan...@aol.com

Richard Lister

unread,
Jul 25, 2001, 12:30:39 PM7/25/01
to
Thanks guys,
but I really <do> want the user to double click and not have to answer
questions (we have some pretty basic users). So it must be a .csv or
another format associated with Excel.
Is there a way I can add macro info to format the column as text to
the beginning of the file I create so it gets run automatically when
double clicked on? - the column in question will always be the same.
tia,

xlj

unread,
Aug 15, 2001, 5:52:12 PM8/15/01
to
When writing the .csv text file, enclose the numerics in double-quotes
and prefix with and equal sign.
E.g.,
a,b,0204,c
would be
a,b,="0204",c

Then your users can double-click the .csv and the numbers'll look ok.
(my much longer post with this answer is on another thread
http://groups.google.com/groups?ic=1&q=msgid:2825eecb.0108141137.ede5cff%40posting.google.com
under the title, "(Re:) import csv and treat numeric values as
text???" if you're interested. One guy didn't think it would work,
but it does for me, so this may be version dependent, I don't know.)


richard...@calderdale.gov.uk (Richard Lister) wrote in message news:<4fef7bad.01072...@posting.google.com>...

Richard Lister

unread,
Aug 24, 2001, 12:38:34 PM8/24/01
to
Your a genious!!!!!
THANKS IDON'TKNOWHOWMANY


xl...@hotmail.com (xlj) wrote in message news:<2825eecb.01081...@posting.google.com>...

0 new messages