+ Reply to Thread
Results 1 to 3 of 3

Determine if Cell Format is M/D/YYYY and Change to Numeric Value in YYYYMMDD Format

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Determine if Cell Format is M/D/YYYY and Change to Numeric Value in YYYYMMDD Format

    Hi,

    I have data files that come in with dates formatted in a variety of ways. Some columns have dates in a YYYY-MM-DD format, and those can be converted into a number with a YYYYMMDD format just by replacing the dashes in the cells with nothing. However, other columns can sometimes come in with dates in a M/D/YYYY format, and these need to be modified to also be in a YYYYMMDD format. How can I write VBA code to evaluate whether the date is in a M/D/YYYY format or not, and if so, how to convert it to YYYYMMDD format?

    BTW, I can't just apply a YYYYMMDD format to all cells because that formats the cells that are now numbers as all #######s.

    Any help that can be suggested will be greatly appreciated!

    Bryan

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064

    Re: Determine if Cell Format is M/D/YYYY and Change to Numeric Value in YYYYMMDD Format

    So what youre implying is EVERY date that contains a forward slash is in the format M/D/YYYY

    Method:
    Take the text value of the cell
    Search for slashes
    If there are any use LEFT MID RIGHT to manipulate the converted m/d/yyyy to yyyymmdd
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Determine if Cell Format is M/D/YYYY and Change to Numeric Value in YYYYMMDD Format

    Hi, Special-K,

    I understand what you're suggesting for the 2nd and 3rd parts of your solution, but wanted to confirm what you meant by "take the text value of the cell." I used a formula to copy the m/d/yyyy formatted cells into a new column, then copied the column and did a paste special-values on it, and finally formatted the entire column as Text. Is that what you were suggesting?

+ 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. YYYYMMDD format change
    By dan789 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 10-14-2015, 06:50 AM
  2. Help require to change a year format to custom yyyy-yyyy format
    By mso3 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-23-2015, 01:04 AM
  3. [SOLVED] Date formula - Change Format to YYYYMMDD from Exported Format
    By haleakala17 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-21-2014, 03:22 PM
  4. [SOLVED] help on vba code to change the error date format as standard format mm/dd/yyyy
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2013, 01:10 AM
  5. Replies: 8
    Last Post: 10-02-2013, 06:23 PM
  6. [SOLVED] how do I change date from mm/dd/yyyy to dd:mm:yyyy format in Excel
    By Jack Wilson in forum Excel - New Users/Basics
    Replies: 4
    Last Post: 07-18-2006, 09:00 AM
  7. [SOLVED] Need macro to change date from yyyymmdd format to mm/dd/yyyy forma
    By Iris in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-16-2005, 06:35 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