VBA convert text to number
Solved
fapfapfap
-
sagessedz Posted messages 4 Status Member -
sagessedz Posted messages 4 Status Member -
Hello,
I have a range of cells in my document where numbers are stored as text... I'd like to have some lines of VBA code to convert them to numbers so that I can use them in calculations.
Could you please help me? (Excel 2007)
Thank you in advance :)
I have a range of cells in my document where numbers are stored as text... I'd like to have some lines of VBA code to convert them to numbers so that I can use them in calculations.
Could you please help me? (Excel 2007)
Thank you in advance :)
6 answers
-
Hello,
For example, to convert A1:A10 into Integers:
Sub test() Dim Array(), i As Long Array = Range("A1:A10") For i = LBound(Array, 1) To UBound(Array, 1) Array(i, 1) = CInt(Array(i, 1)) 'replace CInt with CDbl if decimal numbers Next Range("A1").Resize(UBound(Array, 1), 1) = Array End Sub
--
Best regards,
Franck P