Delete Date data macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top