ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Storing time formats in strings (https://www.excelbanter.com/excel-programming/437523-storing-time-formats-strings.html)

Robert Crandal

Storing time formats in strings
 
Cell "A1" is formatted to accept time data in the format of:

[h]:mm

If I run the following code:

Dim s as String
s = Range("A1").Value
MsgBox s

The message box will display a long floating point number
instead of the time that is displayed in the cell. Is there
a way to store the time that is displayed in a cell into a
string variable??

thnak you



Rick Rothstein

Storing time formats in strings
 
Use the Text property instead of the Value property...

s = Range("A1").Text

--
Rick (MVP - Excel)


"Robert Crandal" wrote in message
...
Cell "A1" is formatted to accept time data in the format of:

[h]:mm

If I run the following code:

Dim s as String
s = Range("A1").Value
MsgBox s

The message box will display a long floating point number
instead of the time that is displayed in the cell. Is there
a way to store the time that is displayed in a cell into a
string variable??

thnak you





All times are GMT +1. The time now is 09:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com