+ Reply to Thread
Results 1 to 5 of 5

VBA Date of Previous Weeks Monday From Current Date

  1. #1
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    VBA Date of Previous Weeks Monday From Current Date

    Hi, I wonder whether someone may be able to help me please.

    I'm trying to calculate the date of the previous weeks Monday from the curernt date and from the searching I've done I've put together the following: `.Cells(1, 3).Offset.Value = Evaluate(Date - (Weekday(Date, 2) + 6))`

    The problem I have when I run this, is that the cells returns the value of `00 Jan 00` when I would expect the 17th November 2014, so clearly I've made a mistake somewhere but I'm not sure where.

    I just wondered whether someone may be able to look at this please and offer some guidance on where I may have gone wrong.

    Many thanks and kind regards

    Chris
    Last edited by hobbiton73; 11-24-2014 at 03:51 AM.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: VBA Date of Previous Weeks Monday From Current Date

    Try this...

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: VBA Date of Previous Weeks Monday From Current Date

    Hi,

    The Evaluate() function take a string as the argument, so your code should be like this :

    Please Login or Register  to view this content.
    Regards
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: VBA Date of Previous Weeks Monday From Current Date

    The line you posted has a syntax error, Offset needs an argument.
    You might use these UDFs.
    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Contributor
    Join Date
    05-26-2012
    Location
    United Kingdom
    MS-Off Ver
    Excel 2013
    Posts
    682

    Re: VBA Date of Previous Weeks Monday From Current Date

    Hi, @sixthsense, @karedog and @mikerickson, thank you all for taking the time to reply to my post and for posting the solutions.

    I continued to work on this, and I too came up with another solution of `.Cells(1, 3).Offset.Value = Date - (Weekday(Date, 2) + 6)` which also seems to work.

    Once again, many thanks for your time and trouble.

    All the best and kind regards

    Chris

+ 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] Return the date of the previous Monday
    By pickslides in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 06-19-2014, 10:01 AM
  2. [SOLVED] Needing formula for date 4 weeks ago on monday
    By Aroy2416 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-14-2013, 09:25 AM
  3. [SOLVED] Display Fridays date (and message) if current date is Monday
    By Pierce Quality in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-26-2013, 09:40 AM
  4. Replies: 3
    Last Post: 12-30-2012, 03:59 PM
  5. Finding the date of previous Monday of Certain date
    By Juhanen II in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-04-2009, 08:40 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