View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
p45cal[_262_] p45cal[_262_] is offline
external usenet poster
 
Posts: 1
Default Excel Convert text to Number


I suspect that could be because you're changing the format of the cells
and not changing it back. Try this on a virgin sheet:


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


Sub test2()
Debug.Print Range("A1").NumberFormat 'to establish pre-existing format i General
With Range("A1:A10")
.NumberFormat = "@"
.Value = "0123" ' also try 123 without quotes
.NumberFormat = "General" 'reset to default format, now you have numbers stored as text.
Debug.Print VarType(Range("A1").Value) ' 8 or vbString
.Value = .Value
Debug.Print VarType(Range("A1").Value) ' 5
End With
End Sub

--------------------





Peter T;705675 Wrote:

Sub test2()[color=blue]
With Range("A1:A10")
.NumberFormat = "@"
.Value = "0123" ' also try 123 without quotes
.Value = .Value
End With

Debug.Print VarType(Range("A1").Value) ' 8 or vbString

With Range("B1")
.Value = 1
.Copy
End With

Range("A1:A10").PasteSpecial Operation:=xlMultiply

Debug.Print VarType(Range("A1").Value) ' 5 or vbDouble

End Sub

Regards,
Peter T

"p45cal" wrote in message
...

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:
'Excel Convert text to Number - The Code Cage Forums'

(http://www.thecodecage.com/forumz/sh...d.php?t=197375)

'Microsoft Office Help - Microsoft Office Discussion - Excel VBA

Programming - Access Programming' (http://www.thecodecage.com/forumz)



--
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