How do I retrieve an Excel cell value in VBA as formatted in the WorkSheet? How do I retrieve an Excel cell value in VBA as formatted in the WorkSheet? vba vba

How do I retrieve an Excel cell value in VBA as formatted in the WorkSheet?


You are confusing a number with its textual representation.

You want the .Text property, not .Value, but then, you might have problems with it.


Use This:

Msgbox Format(Sheet.worksh.Cells(1,1).Value, "0000")


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)