Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Reading numbers as text

I'm using TextToColumns in a macro to convert several huge text files
to a spreadsheet. Some of the raw data is numbers but I need everything
to be copied as text. I found this question numerous times in this
forum but none with the answer I'm looking for.
The problem is, even with the code below the numbers are wrong.
For example, there is a difference between "2" and "02" in my data,
but even with the NumberFormat command the text both variations
will copy as "2", and some numeric strings are converted to SciNote.
Is there a way to copy all text from the raw document as text
without any translation at all?

' Force number format to text:
Cells.Select
Selection.NumberFormat = "@"
' Convert unformatted text to 15 columns:
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(5, 1), Array(11, 1), Array(17,
1), . . . . .

I'm using Excel 2003, with XP Pro.

Mike Henry

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Reading numbers as text

The problem is that all your codes are 1.

Replace:

Array(0, 1), Array(5, 1), Array(11, 1),.........

with:

Array(0, 2), Array(5, 2), Array(11, 2),..........

--
Gary''s Student - gsnu200775


"Mike H" wrote:

I'm using TextToColumns in a macro to convert several huge text files
to a spreadsheet. Some of the raw data is numbers but I need everything
to be copied as text. I found this question numerous times in this
forum but none with the answer I'm looking for.
The problem is, even with the code below the numbers are wrong.
For example, there is a difference between "2" and "02" in my data,
but even with the NumberFormat command the text both variations
will copy as "2", and some numeric strings are converted to SciNote.
Is there a way to copy all text from the raw document as text
without any translation at all?

' Force number format to text:
Cells.Select
Selection.NumberFormat = "@"
' Convert unformatted text to 15 columns:
Selection.TextToColumns Destination:=Range("A1"),
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(5, 1), Array(11, 1), Array(17,
1), . . . . .

I'm using Excel 2003, with XP Pro.

Mike Henry

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Reading numbers as text

Ok, thanks.
That works but the description in the help file sounds like
"0" is for general
"1" is for text
"2" is for a date format.
I guess not.

M.H.
-------------------------------
"Gary''s Student" wrote:
The problem is that all your codes are 1.
Replace:
Array(0, 1), Array(5, 1), Array(11, 1),.........
with:
Array(0, 2), Array(5, 2), Array(11, 2),..........
--
Gary''s Student - gsnu200775


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
Reading Text Sanjay Excel Discussion (Misc queries) 3 July 30th 09 06:32 PM
Reading Numbers in Words Tarig New Users to Excel 1 September 5th 06 02:50 PM
Reading Text and numbers Richard Excel Discussion (Misc queries) 1 August 12th 06 09:22 PM
Date in text box reading mm/dd/yy instead of dd/mm/yy Maddoktor Excel Programming 1 December 19th 05 08:28 AM
Reading a text file WTG Excel Discussion (Misc queries) 2 February 22nd 05 01:27 AM


All times are GMT +1. The time now is 06:33 AM.

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

About Us

"It's about Microsoft Excel"