How do I retrieve an Excel cell value in VBA as formatted in the WorkSheet?
Use This:
Msgbox Format(Sheet.worksh.Cells(1,1).Value, "0000")
You are confusing a number with its textual representation.
You want the .Text
property, not .Value
, but then, you might have problems with it.
Even better, if you're not sure what the format is:
Msgbox Format(Sheet.worksh.Cells(1,1).Value, Sheet.worksh.Cells(1,1).NumberFormat)