View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.programming
Peter T Peter T is offline
external usenet poster
 
Posts: 5,600
Default Excel Convert text to Number

That's just about the slowest way you could contrive to do it. You could try
doing as p45cal suggests (depends, it might not always work)
with rng
..numberformat = "General"
..value = .value
arr = .value
end with

or pastevalues with multiply 1 as I suggested (I also posted code sample)

If you don't want to change cells at all, read the entire range to an array,
then loop the array to change items as required (that'd be very
significantly faster than looping cells though probably not as quick as the
pastespecial multiply approach).

Regards,
Peter T


"JoeBoynton" wrote in message
...[color=blue]
I'll try your suggestion later, couldnt just now
btw i converted the cells from text to number 1 by 1 as follows:

Dim oRange = oWs.Range("A1").Resize(reszRow, rs.Fields.Count)
oRange.Value = TheArray

' rs is from legacy Acucobol vision files read with odbc/dao off of
Linux server

For myOrRow = 1 To ArrayRowCount + 1

' Extra row count above because I loaded headers into row 1

For myOrColumn = 1 To rs.Fields.Count
If IsNumeric(oRange(myOrRow, myOrColumn).Value) Then
oRange(myOrRow, myOrColumn).Value = oRange(myOrRow,
myOrColumn).Value.ToString * 1
End If
Next
Next

This seems to fix the problem, but its a time killer cause it's cell by
cell

Thx for suggestions

"p45cal" wrote:


How are you getting the numbers-stored-as text into cells to test?
I'll do the same and test again..




Peter T;705601 Wrote:

Not here it doesn't -:)

Regards,
Peter T


"p45cal" wrote in message
...

the likes of:


VBA Code:
--------------------


Range("A1:M200")=Range("A1:M200").value
--------------------



seems to work here.


JoeBoynton;705352 Wrote:

Hi,
I need help on how to automate the conversion of a range of Excel



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?u=558
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=197375

http://www.thecodecage.com/forumz

.