VBA code to convert Text to Number

Anonymous
2012-03-27T02:37:30+00:00

HI,

Do everyone knows what is the VBA code to convert Text to Number?  like '01116 convert to 1116.

Best Regards,

Lawrence

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2012-03-27T13:58:48+00:00

Hi,

try this..

convert  text number to number

Sub ConvertTextNumberToNumber()

For Each WS In Sheets

On Error Resume Next

For Each r In WS.UsedRange.SpecialCells(xlCellTypeConstants)

If IsNumeric(r) Then r.Value = Val(r.Value)

Next

Next

End Sub

Was this answer helpful?

60+ people found this answer helpful.
0 comments No comments
Answer accepted by question author
HansV 462.7K Reputation points MVP Volunteer Moderator
2012-03-28T07:47:45+00:00

Some of the cells had a value prefixed with ' to make them text, and they had also been formatted as Text. The solution, as already provided by others, is to format the cells as General.

Was this answer helpful?

30+ people found this answer helpful.
0 comments No comments

31 additional answers

Sort by: Most helpful
  1. HansV 462.7K Reputation points MVP Volunteer Moderator
    2017-03-26T19:12:05+00:00

    What exactly is your point? (This is a very old thread, it was started almost 5 years ago to the day)

    Was this answer helpful?

    0 comments No comments