Excel Formating

S

S kumar

I input the value of 1A , 2P.. in a cell formatted as Text
(This Cell can have any text eg "Suite 100"). When I read
this value from VBA I see a value 1.00.00 AM. Can I not
retain the Value as 1A, 2P.. I tried to change the format
to "General" still no luck..
 
D

Dave Peterson

If you select that cell and look at the formula bar, what do you see?

The only way I could get this:

Option Explicit
Sub test01()
MsgBox Range("a1").Value
End Sub

To return something close to an hour was to change my regional settings (I
changed AM to just A and PM to just P) on the Time Tab.

Then typed 1:00 and formatted the cell as:
hA/P
but even with all that, I saw this as the result:
4.16666666666667E-02

And I saw 01:00:00 in the formula bar, too.

======
And just formatting a cell as text isn't enough to change the previous numeric
entry to text. Try formatting as text and then reenter the value to see if that
helps.

And if all else fails--but I don't think it should, you could retrieve what's
shown in the cell:

msgbox range("a1").text

But that doesn't seem like a reasonable solution to me.
 
Top