-1

Is it possible to get cell's value with it's numberformat, using VBA?

For example, the cell A1 has a value of 10. But the cell shows 10.0. Is it possible to retrieve what it shows on the cell rather than the value of the cell?

Wai Wong
  • 2,671
  • 4
  • 21
  • 17

1 Answers1

1

This is simply done by, e.g.

Debug.Print Range("A1").Text
xificurC
  • 1,168
  • 1
  • 9
  • 17
  • 1
    This is quite literally WYSIWYG and so it will fail in certain cases, e.g. if the cell is too small to contain the number as it's supposed to be formatted. For example, if it's a date but there's not enough space to display it in the cell, `.Text` will return `#######`. If it's 12345678.91 but there's not space enough, it could return `1E+07`. – Jean-François Corbett May 27 '14 at 10:20