Command button help

Posted on 2012-09-17
Last Modified: 2012-09-17
Private Sub CommandButton3_Click()

      Range("B2").Value = Date - Weekday(Date, 3)
      Range("B3").Value = Date - Weekday(Date, 3) + 4

End Sub

If B2 equals the first monday of last week & B3 Friday

How do I alter the code so I get the first Monday of the current week?

i.e 17th & 21st
Question by:Kiwi-123
    LVL 10

    Accepted Solution

    Date - Weekday(Date, vbMonday) + 1
    LVL 19

    Assisted Solution

    Does this work for you?
    Range("B2").Value = Date - Weekday(Date+1, 3)+1

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
    Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
    This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
    This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now