Results 1 to 9 of 9

Convert string dates to proper numerical date format

Threaded View

  1. #1
    Registered User
    Join Date
    07-17-2008
    Location
    us
    Posts
    14

    Convert string dates to proper numerical date format

    Hello, Everyone!

    I am trying to convert text 'dates' like Sat. 1/05/2007 to real dates. I need to find all 'date' cells in range B4:B100 (they are filled in yellow), strip off the offending text (i.e. Sat.), and use DateValue to turn the rest 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 help from experts in forums, 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.ColorIndex <> 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
    Last edited by VBA Noob; 07-21-2008 at 01:06 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1