Forum Discussion
SeppT03
Apr 19, 2023Copper Contributor
Converting Text to numbers
I have statements in CSV format converted to text in excel. Pproblem the numbers are seperated with a comma as the thousand seperator and a dot for the decimal i.e. 10,562.98. They can therefore not...
- Apr 19, 2023
NUMBERVALUE does it - see attachment columns F-G
Sue
May 21, 2023Copper Contributor
Hi Nikolino,
I also have a problem of converting the string (from a textbox) "1,234.56" to 1234.56 using VBA. I have tried to convert it both before and after pasting without success so far. I do not understand the bit about "If IsNumeric(cell)" because the problem for me is that it will paste as a string. Using Val("1,234.56") pastes as 1.00 ie VBA has not recognized it as numeric either. I have not managed to convert the string to a number before or after pasting. I think it would be better to convert it before pasting to a variable and leave the txtbox in the form with the comma. I realise the problem is the comma but surely there is some function that handles this?
Sue
I also have a problem of converting the string (from a textbox) "1,234.56" to 1234.56 using VBA. I have tried to convert it both before and after pasting without success so far. I do not understand the bit about "If IsNumeric(cell)" because the problem for me is that it will paste as a string. Using Val("1,234.56") pastes as 1.00 ie VBA has not recognized it as numeric either. I have not managed to convert the string to a number before or after pasting. I think it would be better to convert it before pasting to a variable and leave the txtbox in the form with the comma. I realise the problem is the comma but surely there is some function that handles this?
Sue
HansVogelaar
May 21, 2023MVP
Alternatively, use Data > Text To Columns.
In VBA:
Range("...").TextToColumns
Alternatively
With Range("...")
.Value = .Value
End With