Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to delete rows based on date PMBO Excel Discussion (Misc queries) 4 February 18th 09 01:50 PM
Macro to delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 01:18 PM
Macro to delete certain data Lindsey M Excel Worksheet Functions 2 March 7th 05 05:03 PM
macro to find date format in a cell and delete that entire row vikram Excel Programming 8 April 30th 04 06:00 PM
Macro want delete the date row? Shetty Excel Programming 5 March 3rd 04 02:08 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"