I have the following issue.
When I try to do :
cell.value=CStr(cell.value)
it works with numbers like 6,91. But when I try with numbers like 6,911 I get 6911 in return when I just want 6,911 instead. I'm using commas because I'm in Europe, I guess maybe VBA mixes it up with the American way of writing thousands with a comma.
Indeed, here I only want a decimal with 3 figures after the comma
CodePudding user response:
This does not what you expect it to do
cell.value=CStr(cell.value)
Here CStr(cell.value)
will turn it into a String
but if you write a string into a cell that looks like a number Excel "thinks" and turns it back into a number. Here comes the confusion.
If you want to format that cell as text use
Cell.NumberFormat = "@"
Cell.Value = Format$(cell.Value, "0.000")
or use Cell.Value = "'" & Format$(cell.Value, "0.000")
CodePudding user response:
Consider:
cell.Value=cell.Text
This should capture the contents WYSIWYG.