I am having issues with the Excel trim function. A lot of the times the data I extract is accompanied with extra white spaces after the string of information e.g., "1234566 ". I have historically used the trim function in VBA and it seems to do the job well, but I have stumbled an issue when it comes to cells with long strings of just numbers.
Here is the code:
Dim C As Range
For Each C In ActiveSheet.UsedRange
With C
C.Value = Trim (C)
End With
Next C
This works for the majority of cases but e.g., if I use this code on along digit with spaces to the right "12355557899200123 ", Excel's trim function appears to Trim but change the value of the number (not good) by cutting off several of the last digits in this case 12355557899200123 became -> 12355557899200100 and 23 were replaced by 00 which can lead to miscalculations later :(((((.
Thank you in advance for your help and suggestions!
Excel has a precision of 15 digits, see here for these kind of limitations (Scroll down to Calculation specifications and limits). 12355557899200123 has a length of 17 digits which means you will loose the last two digits when you place this into an Excel sheet.