I’m working with a workbook which uses a strange space as a thousands separator. The numbers including this separator are treated as text by Excel. When I remove this separator using the Find & Replace tool, the numbers get properly recognized as numbers. When I do the same using VBA, using the Cells.Replace method, the numbers keep being stored as text. A green corner then appears on the cells containing these numbers, allowing me to convert them to the number format, but this option doesn’t seem to be exploitable in VBA as this action isn’t recorded by the macro recorder.
I may copy my worksheet’s cells to an array, then loop through the values to replace the thousands separator, then paste the array back to the worksheet. My question is: is there a more efficient way to remove these thousands separators so that my numbers get treated as numbers?
Numbers with a non-break space as thousands separator and a coma as decimal separator were stored as text. Using the
Cells.Replacemethod in VBA to remove the space didn’t convert the values to number format, instead leaving them stored as text. The solution was usingCells.Replacea second time to replace comas with dots for VBA to treat the values as numbers and copy them to the worksheet as such. Excel then formats the numbers according to the regional settings (replacing dots back with comas if necessary).