ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Convert to Number (https://www.excelbanter.com/excel-programming/334937-convert-number.html)

Michael Wise[_26_]

Convert to Number
 

Column A of a varying number of rows have a 9 digit number leading wit
a Zero. Is there a way to remove the leading Zero in VBA. I ca
manually do this with the error checking wizard but I really need it t
do this within my code.

Example: 097894462 needs to be 97894462

ThXs,
Michae

--
Michael Wis
-----------------------------------------------------------------------
Michael Wise's Profile: http://www.excelforum.com/member.php...nfo&userid=699
View this thread: http://www.excelforum.com/showthread.php?threadid=38835


Peter81

Convert to Number
 

Michael this should do the job.

Just change the "For n = 1 to 10" to the required rows.

Sub Text_to_number()

For n = 1 To 10
If IsNumeric(Range("A" & n).Value) = True And Range("A" & n).Text _
< "" And Range("A" & n).HasFormula = False Then
Range("A" & n) = Val(Range("A" & n))
End If
Next

End Sub


--
Peter81
------------------------------------------------------------------------
Peter81's Profile: http://www.excelforum.com/member.php...o&userid=25353
View this thread: http://www.excelforum.com/showthread...hreadid=388353



All times are GMT +1. The time now is 02:27 AM.

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