![]() |
Delete Date data macro
I get an excel sheet that has the date format like this:
8/9/04 1:25:43 PM EDT How whould I set up a macro that would delet all that data after the year number? can this be done? THnanks |
Delete Date data macro
For Each cell In Selection If IsDate(cell.Value) Then cell.Value = Int(cell.Value) cell.NumberFormat = "m/d/yy" End If Next cell -- HTH RP (remove nothere from the email address if mailing direct) "KAnoe" wrote in message ... I get an excel sheet that has the date format like this: 8/9/04 1:25:43 PM EDT How whould I set up a macro that would delet all that data after the year number? can this be done? THnanks |
Delete Date data macro
Bob,
How would I use this code? Would I put it in a Macro? "Bob Phillips" wrote: For Each cell In Selection If IsDate(cell.Value) Then cell.Value = Int(cell.Value) cell.NumberFormat = "m/d/yy" End If Next cell -- HTH RP (remove nothere from the email address if mailing direct) "KAnoe" wrote in message ... I get an excel sheet that has the date format like this: 8/9/04 1:25:43 PM EDT How whould I set up a macro that would delet all that data after the year number? can this be done? THnanks |
Delete Date data macro
Hi, Bob:
His data is 8/9/04 1:25:43 PM EDT The final "EDT" means that neither Excel or VB recognize it as a date. Maybe this will work For Each cell In Selection With Cell X = .Value i = Instr(X, " ") If i 0 Then .Value = CDate(Left$(X, i - 1)) .NumberFormat = "m/d/yy" End If End With Next cell On Sat, 6 Nov 2004 00:56:16 -0000, "Bob Phillips" wrote: For Each cell In Selection If IsDate(cell.Value) Then cell.Value = Int(cell.Value) cell.NumberFormat = "m/d/yy" End If Next cell |
All times are GMT +1. The time now is 05:45 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com