+ Reply to Thread
Results 1 to 3 of 3

Date changing to wrong month in code

Hybrid View

  1. #1
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Date changing to wrong month in code

    Hi guys and girls

    Having trouble with the following bit of code, where it correctly picks up that Tdate -3 = 02/08/19 (Tdate being 5/8/19) however, as the IF ends, it changes to 30/7/2019.

    Happened Monday as well apparently (was out so did not see)

    Screen shots of watch attached for you to see the changes

    All help greatly rec'd as usual


    TDate = Date
    
    If Weekday(Date) = vbMonday Then
    
    
        TDate = TDate - 3
    Else: TDate = TDate - 1
    End If

    Many thanks

    tdate minus 3.PNGafter if.PNG

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: Date changing to wrong month in code

    I don't see the problem. If you change TDate to 2/8/2019 then TDate - 3 is obviously going to change to 30/7/2019.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    05-10-2013
    Location
    london
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Date changing to wrong month in code

    Sorry, had some help and found the user error

+ 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] Wrong number of arguments when trying to obtain Month(Date)
    By vamosj in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-11-2015, 02:12 PM
  2. Dynamic chart automatically changing its range if we select wrong date
    By maniknandi in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-06-2013, 12:46 AM
  3. Date isssue keeps changing the month and day
    By Lextar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2013, 10:50 AM
  4. Changing the date in a cell every month
    By bopsgtir in forum Excel General
    Replies: 3
    Last Post: 12-21-2010, 01:51 PM
  5. Pivot table showing wrong data (date not month)
    By rushdenx1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-17-2010, 06:59 AM
  6. Changing a date back one month
    By John in forum Excel General
    Replies: 7
    Last Post: 02-07-2006, 08:15 AM
  7. Changing today's date to the first of the month
    By Scott in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-22-2005, 10:25 AM

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