ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple String Conversion - HELP (https://www.excelbanter.com/excel-programming/331435-simple-string-conversion-help.html)

prepotency[_3_]

Simple String Conversion - HELP
 

Anyone know off-hand the command to convert a number:

0000000456

to:

4.56

I tried this:
Application.FixedDecimal = True
Application.FixedDecimalPlaces = 2

Which works, but not if you're copying the data from another workbook.

Any ideas?


Garrett (MIS)


--
prepotency
------------------------------------------------------------------------
prepotency's Profile: http://www.excelforum.com/member.php...o&userid=24155
View this thread: http://www.excelforum.com/showthread...hreadid=378042


Kaak[_9_]

Simple String Conversion - HELP
 

Dim TempNumber as single

TempNumber = "000000456"

TempNumber = TempNumber / 100


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=378042


mangesh_yadav[_286_]

Simple String Conversion - HELP
 

=VALUE(A1)

where A1 has your number 000456

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=378042


mangesh_yadav[_285_]

Simple String Conversion - HELP
 

in VBA simply do:
a = Int( "0000456")

Mangesh


--
mangesh_yadav
------------------------------------------------------------------------
mangesh_yadav's Profile: http://www.excelforum.com/member.php...o&userid=10470
View this thread: http://www.excelforum.com/showthread...hreadid=378042


prepotency[_4_]

Simple String Conversion - HELP
 

hahahaha wow - didn't even occur to me to divide by 100. That makes me
laugh.

Here's something else I came up with if anyone needs it later:

Sub insertDecimal()

Dim theInput As String
theInput = "0000000875"
Dim leftText, rightText As String

leftText = left(theInput, Len(theInput) - 2)
rightText = right(theInput, 2)

Dim newText

newText = leftText + "." + rightText

Cells(1, 1).Value = newText



End Sub


thanks for the replies all


--
prepotency
------------------------------------------------------------------------
prepotency's Profile: http://www.excelforum.com/member.php...o&userid=24155
View this thread: http://www.excelforum.com/showthread...hreadid=378042



All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com