How to keep ms excel from expanding country codes?
I have an Excel containing country codes like "AD". When I try to access this cell in VBA then its value, text or formula returns Andorra. Why the heck is excel doing this? And how can I get the country code? This is driving my crazy ... :-)
EDIT 1:
For r = 1 To 32000
If ws.Cells(r, 1) = "" Then Exit For
Debug.Print ws.Cells(r, 1)
Debug.Print ws.Cells(r, 1).Formula
Debug.Print ws.Cells(r, 1).Text
Debug.Print ws.Cells(r, 1).Value
Debug.Print ws.Cells(r, 1).Value2
'Write #i, ws.Cells(r, 1), ws.Cells(r, 2), ws.Cells(r, 3)
Next r
Is returnin all the same "Andorra"
EDIT 2:
You will not beleve what happend. Someone has hidden a column - and I could开发者_运维问答 not see but vba can see ... shame But I swear, I have not see this damn hidden col ... sorry. Sometimes its nevertheless more a user fault than a ms fault :-) sorry!
Make sure to format your cells as "text". If that isn't working then there is something going on that isn't normal and we'll need more info.
If that doesnt work try reading the cell into VBA and look at the locals windows to see the properties. Also, you might want to they watching a cell in debug and enter a value and see what happens to it to track where the change is coming from.
精彩评论