+ Reply to Thread
Results 1 to 3 of 3

Date format and vba weekday problem

  1. #1
    Registered User
    Join Date
    05-29-2012
    Location
    Wilmingotn DE USA
    MS-Off Ver
    Excel 2016
    Posts
    67

    Date format and vba weekday problem

    Dear friends. I gave up so there is this thread. I am starting with file in .txt created by the outside device. The date is always in format d-mmm-yy. Can not change it (why?). Then I am copying /pasting the sheet on the sheet in excel. I am still not able to change the date format. THe vba code is not calculating following thing = worksheetfunction.weekday(cell1). If cell1 is in format m/d/yy then worksheetfunction.weekday works well if the cell1 is in format d-mmm-yy worksheetfunction.weekday(cell1) does not work. THe bad thing is that I am not able to change the date format after copying from .txt and pasting in excel sheet. I am not able to change date format before copying. Any suggestions??

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Date format and vba weekday problem

    Then I am copying /pasting the sheet on the sheet in excel. I am still not able to change the date format.
    It is difficult to be certain without an example, but my guess is that Excel/VBA is not recognizing the date as a real date, so it is importing it as a text string.

    One solution might be to look at the importation step. Perhaps somewhere in the importation step you can change something so that Excel/VBA will recognize it as a date.

    The other solution would be to use Excel's text manipulation functions to extract the date, month, and year, then recombine into something Excel/VBA can recognize as a date using either the DATEVALUE() or DATE() functions.

    The exact implementation of either of those solutions depends on exactly what your file/code is doing.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    05-29-2012
    Location
    Wilmingotn DE USA
    MS-Off Ver
    Excel 2016
    Posts
    67

    Re: Date format and vba weekday problem

    Thanks a lot. Will try your suggestions.

+ 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. Replies: 8
    Last Post: 06-21-2016, 08:56 AM
  2. Excel VBA code to return weekday name from a date then autofilters for userdefined weekday
    By studyengineering in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-10-2016, 03:24 PM
  3. [SOLVED] Calculate weekday end date based on sum of weekday start date and cell value
    By Rerock in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-01-2014, 09:17 AM
  4. Replies: 5
    Last Post: 02-08-2013, 11:06 AM
  5. How to format the date with weekday?
    By smartcard in forum Excel General
    Replies: 1
    Last Post: 04-15-2010, 03:33 AM
  6. [SOLVED] nth weekday of the the month date problem
    By Thrashman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2006, 03:15 PM
  7. Excel Date Sort Format: Weekday, Month Day, Year
    By mrsinnister in forum Excel General
    Replies: 2
    Last Post: 03-23-2006, 04:15 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