+ Reply to Thread
Results 1 to 2 of 2

How to read the text of cutom time e.g. 7:00 AM?

  1. #1
    Registered User
    Join Date
    07-21-2005
    Posts
    28

    How to read the text of cutom time e.g. 7:00 AM?

    Hi!

    In my cell, it uses the Custom Number for a time h:mm AM/PM. That is: the cell is defined as Number with custom format h:mm AM/PM.

    It shows right in the cell. For example, it shows as 7:00 AM. However, when I read the cell using VBA, it reads as 0.29166. For example, lets row 1, col is shown as 7:00 AM, VBA will read cells(1, 1) as 0.29166 instead of 7:00 AM.

    Can anybody help me with this? How can I read the time as it is showed in the cell?

    Thank you very much for your help.

    Regards,
    Aijun.

  2. #2
    Valued Forum Contributor Excelenator's Avatar
    Join Date
    07-25-2006
    Location
    Wantagh, NY
    Posts
    333
    Use

    CDate(Range("A1").Value)
    ---------------------------------------------------
    ONLY APPLIES TO VBA RESPONSES WHERE APPROPRIATE
    To insert code into the VBE (Visual Basic Editor)
    1. Copy the code.
    2. Open workbook to paste code into.
    3. Right click any worksheet tab, select View Code
    4. VBE (Visual Basic Editor) opens to that sheets object
    5. You may change to another sheets object or the This Workbook object by double clicking it in the Project window
    6. In the blank space below the word "General" paste the copied code.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1