• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to Convert Text into Number

I want to know how we can convert Text into Number format using VBA. I am attaching the sample file for your ready reference.

In my sample file column D I have a value in " Text Format " I want to convert the same Column D in "Number Format"

Which should look like Column C.

Thanks in Advance.

Regards,
Harsh
 

Attachments

  • Sample File.xlsm
    9.7 KB · Views: 9
How should Char(151) in cell D4 be treated? Should it be 0?

At any rate, you can do something like below.
Code:
Sub Demo()
With Range("D2:D" & Cells(Rows.Count, "D").End(xlUp).Row)
    .NumberFormat = "#,##0"
    .Replace Chr(151), 0, xlWhole
End With
End Sub
 
Hey Chihiro,

Thanks a Lot

I am looking for the exact solution which you did in your code.

Regarding Char(151) you guess it right the value should be replaced by 0 and same should be converted into number format.

Thanks once again for taking your time and help me on this

Really appreciate your efforts.
 
Back
Top