convert date to number in excel - Excel Date to String conversion
Here is a VBA approach:
Sub change() toText Sheets(1).Range("A1:F20") End Sub Sub toText(target As Range) Dim cell As Range For Each cell In target cell.Value = cell.Text cell.NumberFormat = "@" Next cell End Sub
If you are looking for a solution without programming, the Question should be moved to SuperUser.
convert date to string excel
In a cell in Excel sheet I have a Date value like:
I want to convert that Date to Text and also want the Text to look exactly like Date. So a Date value of
01/01/2010 14:30:00 should look like
01/01/2010 14:30:00 but internally it should be Text.
How can I do that in Excel?
In some contexts using a ' character beforehand will work, but if you save to CSV and load again this is impossible.
In Excel 2010, marg's answer only worked for some of the data I had in my spreadsheet (it was imported). The following solution worked on all data.
Sub change() toText Selection End Sub Sub toText(target As range) Dim cell As range Dim txt As String For Each cell In target txt = cell.text cell.NumberFormat = "@" cell.Value2 = txt Next cell End Sub
Couldnt get the TEXT() formula to work
Easiest solution was to copy paste into Notepad and back into Excel with the column set to Text before pasting back
Or you can do the same with a formula like this
=DAY(A2)&"/"&MONTH(A2)&"/"&YEAR(A2)& " "&HOUR(B2)&":"&MINUTE(B2)&":"&SECOND(B2)