+ Reply to Thread
Results 1 to 5 of 5

Worksheet function for cell's displayed value

  1. #1
    Registered User
    Join Date
    01-12-2011
    Location
    Reading, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Worksheet function for cell's displayed value

    Hi

    In VBA a cell has both a value and a text property - the value is the behind-the-scenes value stored in the cell and the text is the displayed text. eg if you format a cell as a date and enter today's date, the cell's value would be 40878 and the cell's text would be something like "12/01/2011"

    So I want to know if there's a worksheet function that will return a cell's displayed text rather than its underlying value.

    Any help would be much appreciated!

    thanks

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Worksheet function for cell's displayed value

    Not per se - if you know the format you can ape it via the TEXT function, eg:

    Please Login or Register  to view this content.
    Alternatives would as you say require UDF or use of XLM GET.CELL calls via Defined Names (type_num 53)

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet function for cell's displayed value

    Hi,

    I don't understand your question. If A1 contains =TODAY(() it will as you say return 12/01/2011 and have the underlying value 40878.

    If in B1 you enter =A1, you'll still get the text 12/01/2011 in B1

    There is a TEXT() function but as I say I don't understand your request. Can you clarify, if necessary upload and example workbook which shows the result you expect.

    Rgds
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Registered User
    Join Date
    01-12-2011
    Location
    Reading, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Worksheet function for cell's displayed value

    Thanks for your replies. I ended up using the text() function with a date format string but as it's so easy to get the displayed text via VBA i thought you should be able to do the same using a worksheet function in a macro-disabled workbook without having to recreate the date format.

    Richard, the reason for my question was that i had a column of dates and a column of other text which I needed to concatenate together into a new column. Its true that if (following your example) you enter =A1 in B1, you get the formatted date. However if you want to concatenate anything else with that date string, the date serial comes out instead. Eg put '="The date is " & A1' in B1 and you'll get "The date is 40878" rather than "The date is 12/01/2011"
    Last edited by bmelvin; 01-12-2011 at 12:02 PM.

  5. #5
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Worksheet function for cell's displayed value

    Hi,
    OK understood.
    In that case use
    Please Login or Register  to view this content.
    Rgds

+ 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