Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I get the displayed value of a cell in MS Excel ( for text that was converted to dates)?

Excel File Origin

I have an Excel file that was originally a CSV file. At this time I don't have access to the original CSV file. When the CSV file was originally opened in Excel, many of cells in the Date column were automatically converted.

Example Values

Here is an example of some of the items from the Date column ( spacing represents left and right aligned cells, mostly to show that the second date was not converted):

exhibit 1:

        3/1/71
12/01/1882
Fall 1988
          1993

And if I choose one of those cells and right click and select formatting I will get different things:

m/d/yy
General
General
General

Possible Logic

So looks like excel hasn't converted the 12/01/1882 date - maybe because it is "too old" or maybe for another reason.

If I select the whole column and change it to "General" formatting it then gives me this ( text left aligned, numbers right aligned):

       25993
12/01/1882
Fall 1988
        1993

What I Want

I'd like to have one column where I have the format set to "General" or "Text" and it would have the dates that were displayed from exhibit 1 above.

I saw this question about using a DataFormatter class (looks like Java?) and some similar questions that use Macros and VB scripting - but if at all possible I would really like a way to use an excel function to do this.

What I've tried

I've tried using these things which have not worked:

CONCATENATE - to get the date field, and prepend it with a space
INDIRECT(ADDRESS(ROW(),5)) - get the value indirectly
VALUE() - get the "value' of the cell - opposite of what I want
TEXT() - can explicitly specify format but still can't make it work
CELL() - can be used to get cell information such as "contents" - no luck with this but I did see that I could use it also to get format which would tell me if the cell is displayed as a number or as "general" which could then possibly used with an IF function somehow to convert a number that is displayed as a date back to an actual date... possibly?

Copy Paste Method

One method I saw which seems to work is to select the values, copy and paste them into notepad, and then copy and paste them back into excel (it effectively gives the displayed value - which is what I want )

The only problem is that I would like to have a function to do this because the excel sheet has a few hundred thousand rows in it.

share|improve this question
    
If notepad is a solution you should be able to just cipy the cells and then "paste special" and choose text only –  Mattias Åslund Nov 21 '13 at 17:50
    
@MattiasÅslund - yes but for hundreds of thousands of rows is the only issue... –  cwd Nov 21 '13 at 18:16
    
How about just selecting the proper date format for the column and then left justify the cells? It will look right although some cells are actually still dates –  Mattias Åslund Nov 21 '13 at 18:26
    
Thanks - I need the actual values as text - the file is going to get imported into another program –  cwd Nov 21 '13 at 19:01
add comment

1 Answer

up vote 0 down vote accepted

If you have shown us the full range of possible formats, this should work:

=TEXT(A1, IF(CELL("format",A1)="D4", "m/d/yy", "General"))

If you have date formats other than m/d/yy, add tests for them.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.