Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default Please help me finish this simple macro

Hello, Everyone!

I am trying to convert text dates to real dates. I need to find all yellow
cells in range B4:B100, strip off the offending text (i.e. Sat. or Thurs),
and use DateValue to turn the rest (which looks like 1/05/2007, but sometimes
1/05/07) into a proper, numerical date in the ddd mm/dd/yy format, arial,
bold, 10pt, and centered in place.

I've spent days trying to write this macro. I've had excellent help from
people on here, but whenever I need to make any slight modification, a
trainwreck ensues. Please see the code below.

Sub switchDate()
Dim MyDate As String
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndext < xlNone Then
cell.Value = MyDate.Value
MyDate = Trim(MyDate)
If InStr(MyDate, " ") 0 Then
MyDate = Mid(MyDate, InStr(MyDate, " ") + 1)
End If
MyDate = DateValue(MyDate)
End If
Next
End Sub

This doesn't even begin to work and I can't begin to guess why. Could
somebody out there please make the tweaks and tell me what I did wrong, that
I might not do it hence?

I thank you greatly, and have a terrific day.

Arlen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Please help me finish this simple macro

I haven't tried it yet but if you turn on the macrro recorder, then format
the string date to a real date format, manaully, I can almost guarantee that
your code will be recorded.

ML

"Arlen" wrote:

Hello, Everyone!

I am trying to convert text dates to real dates. I need to find all yellow
cells in range B4:B100, strip off the offending text (i.e. Sat. or Thurs),
and use DateValue to turn the rest (which looks like 1/05/2007, but sometimes
1/05/07) into a proper, numerical date in the ddd mm/dd/yy format, arial,
bold, 10pt, and centered in place.

I've spent days trying to write this macro. I've had excellent help from
people on here, but whenever I need to make any slight modification, a
trainwreck ensues. Please see the code below.

Sub switchDate()
Dim MyDate As String
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndext < xlNone Then
cell.Value = MyDate.Value
MyDate = Trim(MyDate)
If InStr(MyDate, " ") 0 Then
MyDate = Mid(MyDate, InStr(MyDate, " ") + 1)
End If
MyDate = DateValue(MyDate)
End If
Next
End Sub

This doesn't even begin to work and I can't begin to guess why. Could
somebody out there please make the tweaks and tell me what I did wrong, that
I might not do it hence?

I thank you greatly, and have a terrific day.

Arlen

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Please help me finish this simple macro

Ok, I just tried that.
This is what I got

Range("Cell").Select 'or Activecell.Select
Selection.NumberFormat = "m/d/yy;@"

Is that what you are looking for?

ML

"Arlen" wrote:

Hello, Everyone!

I am trying to convert text dates to real dates. I need to find all yellow
cells in range B4:B100, strip off the offending text (i.e. Sat. or Thurs),
and use DateValue to turn the rest (which looks like 1/05/2007, but sometimes
1/05/07) into a proper, numerical date in the ddd mm/dd/yy format, arial,
bold, 10pt, and centered in place.

I've spent days trying to write this macro. I've had excellent help from
people on here, but whenever I need to make any slight modification, a
trainwreck ensues. Please see the code below.

Sub switchDate()
Dim MyDate As String
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndext < xlNone Then
cell.Value = MyDate.Value
MyDate = Trim(MyDate)
If InStr(MyDate, " ") 0 Then
MyDate = Mid(MyDate, InStr(MyDate, " ") + 1)
End If
MyDate = DateValue(MyDate)
End If
Next
End Sub

This doesn't even begin to work and I can't begin to guess why. Could
somebody out there please make the tweaks and tell me what I did wrong, that
I might not do it hence?

I thank you greatly, and have a terrific day.

Arlen

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 47
Default Please help me finish this simple macro

Hi Arlen
If you don't mind me asking; why did your date format start out as a String?
Are you retreiving a date from a user?

ML


"ML0940" wrote:

Ok, I just tried that.
This is what I got

Range("Cell").Select 'or Activecell.Select
Selection.NumberFormat = "m/d/yy;@"

Is that what you are looking for?

ML

"Arlen" wrote:

Hello, Everyone!

I am trying to convert text dates to real dates. I need to find all yellow
cells in range B4:B100, strip off the offending text (i.e. Sat. or Thurs),
and use DateValue to turn the rest (which looks like 1/05/2007, but sometimes
1/05/07) into a proper, numerical date in the ddd mm/dd/yy format, arial,
bold, 10pt, and centered in place.

I've spent days trying to write this macro. I've had excellent help from
people on here, but whenever I need to make any slight modification, a
trainwreck ensues. Please see the code below.

Sub switchDate()
Dim MyDate As String
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndext < xlNone Then
cell.Value = MyDate.Value
MyDate = Trim(MyDate)
If InStr(MyDate, " ") 0 Then
MyDate = Mid(MyDate, InStr(MyDate, " ") + 1)
End If
MyDate = DateValue(MyDate)
End If
Next
End Sub

This doesn't even begin to work and I can't begin to guess why. Could
somebody out there please make the tweaks and tell me what I did wrong, that
I might not do it hence?

I thank you greatly, and have a terrific day.

Arlen

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 735
Default Please help me finish this simple macro

This should do it......

Sub switchDate()
Dim cell As Range
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndex < xlNone And InStr(Trim(cell.Value), " ") 0
Then
With cell
.Value = Format(Mid(cell.Value, InStr(cell.Value, " ") + 1), "ddd
mm/dd/yy")
.HorizontalAlignment = xlCenter
With .Font
.Name = "Arial"
.Size = 10
.Bold = True
End With
End With
End If
Next
End Sub

--

Regards,
Nigel




"Arlen" wrote in message
...
Hello, Everyone!

I am trying to convert text dates to real dates. I need to find all
yellow
cells in range B4:B100, strip off the offending text (i.e. Sat. or Thurs),
and use DateValue to turn the rest (which looks like 1/05/2007, but
sometimes
1/05/07) into a proper, numerical date in the ddd mm/dd/yy format, arial,
bold, 10pt, and centered in place.

I've spent days trying to write this macro. I've had excellent help from
people on here, but whenever I need to make any slight modification, a
trainwreck ensues. Please see the code below.

Sub switchDate()
Dim MyDate As String
For Each cell In ActiveSheet.Range("B4:B100")
If cell.Interior.ColorIndext < xlNone Then
cell.Value = MyDate.Value
MyDate = Trim(MyDate)
If InStr(MyDate, " ") 0 Then
MyDate = Mid(MyDate, InStr(MyDate, " ") + 1)
End If
MyDate = DateValue(MyDate)
End If
Next
End Sub

This doesn't even begin to work and I can't begin to guess why. Could
somebody out there please make the tweaks and tell me what I did wrong,
that
I might not do it hence?

I thank you greatly, and have a terrific day.

Arlen


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 start and finish date from rows Marylou Excel Worksheet Functions 16 August 17th 09 02:58 PM
How to Create Sound Alert and Email Alert when Macro is Finish Tom Ogilvy Excel Programming 0 November 30th 06 11:12 PM
How to Create Sound Alert and Email Alert when Macro is Finish Bob Phillips Excel Programming 0 November 30th 06 09:21 PM
One more and I'll finish this complicated macro Duncan_J Excel Programming 1 November 16th 04 04:39 PM
Need help to finish function.... Dan B Excel Programming 4 October 7th 03 10:06 PM


All times are GMT +1. The time now is 10:19 AM.

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

About Us

"It's about Microsoft Excel"