+ Reply to Thread
Results 1 to 4 of 4

Fix column with multiple improper date formats

  1. #1
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Fix column with multiple improper date formats

    I have a huge report that gets generated that has a column of dates. However some of the dates are text strings and need to be corrected. THere are three different ways the date appears:

    9/20/2021
    Mon Jun 14 at 6:00am America/Chicago
    Mon Aug 2

    I am trying to write a VBA macro that corrects all of them.
    I am using
    Please Login or Register  to view this content.
    This is close but it leaves me with

    9/20/2021
    Mon Jun 14
    8/2/2021

    For some reason the middle one is still not being seen as a date. Even if I run the macro again it doesn't correct that middle one.

    What am I missing? - it should correct them automatically but it is not. Even if I rerun the macro without the "at" replace part it doesn't correct the one incorrect one. I know this has to do with it being text and not a number (tested using ISNUMBER) but how to correct?
    Last edited by NewYears1978; 09-22-2021 at 03:05 PM.

  2. #2
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,459

    Re: Fix column with multiple improper date formats

    Please Login or Register  to view this content.
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,659

    Re: Fix column with multiple improper date formats

    For Each cel In Range("B2").End(xlDown)
    Your code only loops through one cell; the last one. Try this...

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  4. #4
    Forum Contributor NewYears1978's Avatar
    Join Date
    03-15-2010
    Location
    Forney, TX
    MS-Off Ver
    Excel 2016
    Posts
    962

    Re: Fix column with multiple improper date formats

    Quote Originally Posted by AlphaFrog View Post
    Your code only loops through one cell; the last one. Try this...

    Please Login or Register  to view this content.
    Yeah, lol. I am stupid. Rookie mistake and funny I didn't catch it even after reading it over and over. It works now

    Quote Originally Posted by bsalv View Post
    Please Login or Register  to view this content.
    Diff solution but always works Thanks to you both!

    This is literally my favorite forum on the web, all time, without question. I always get help and constantly learn new things here! Love it!
    Last edited by NewYears1978; 09-22-2021 at 03:37 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Different Date Formats In Same Column
    By Samiramriti in forum Excel General
    Replies: 9
    Last Post: 11-14-2017, 10:19 AM
  2. [SOLVED] Multiple Date Formats
    By leebird in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-29-2016, 04:14 PM
  3. [SOLVED] Multiple Date and Text Formats In One Column
    By nevi in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 06-25-2014, 07:00 PM
  4. Various date formats in same column
    By mardiefe in forum Excel General
    Replies: 5
    Last Post: 06-22-2014, 09:42 AM
  5. Multiple date formats within a single column
    By the big frame in forum Excel General
    Replies: 3
    Last Post: 02-22-2012, 05:02 PM
  6. How to change multiple date formats in same column
    By muchado in forum Excel General
    Replies: 6
    Last Post: 11-10-2010, 01:37 AM
  7. Multiple date formats to 1
    By somesoldiers in forum Excel General
    Replies: 6
    Last Post: 07-29-2009, 12:16 PM

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