VBA code to convert Text to Number

HI,

 

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

 

Best Regards,

Lawrence

Answer
Answer
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

-----------------------------
Office 365 on Windows 10

68 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Answer
Answer
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.
---
Kind regards, HansV
https://www.eileenslounge.com

34 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

 
 

Question Info


Last updated March 17, 2020 Views 164,106 Applies to: