+ Reply to Thread
Results 1 to 4 of 4

VBA to fill in date values of current week beginning with Monday using button.

  1. #1
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    VBA to fill in date values of current week beginning with Monday using button.

    I am having trouble figuring out a VBA code to put the date value of the current week beginning with Monday, into a column of cells (B5 thru B11) using a 'button'.

  2. #2
    Registered User
    Join Date
    10-30-2012
    Location
    Modlin , Poland
    MS-Off Ver
    Excel 2003, Excel 2007
    Posts
    42

    Re: VBA to fill in date values of current week beginning with Monday using button.

    hi,
    you can try this:

    Sub Dates()
    Dim i As Integer
    Range("b5").Select
    For i = 1 To 7

    ActiveCell.FormulaR1C1 = "=TODAY() - WEEKDAY(TODAY()*0.2)+" & i
    ActiveCell.Offset(1, 0).Select

    Next i
    Range("b5:b11").NumberFormat = "m/d/yyyy"

    End Sub

  3. #3
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    Re: VBA to fill in date values of current week beginning with Monday using button.

    That works Perfectly. Thank you.

  4. #4
    Registered User
    Join Date
    05-14-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Office 2013
    Posts
    19

    Re: VBA to fill in date values of current week beginning with Monday using button.

    Is there a way to have it give the Previous week's dates beginning with Monday? *(Example: If I pressed the button on Tuesday July 9th could it give the dates of Monday July 1st thru Sunday July 7th?)

    When using the other code after protecting the sheet it gives (error 400) after pressing the button but it still puts the correct values in the cells. The cells that are used are not protected but other adjacent cells are. I can't figure out why it is giving that error or how to correct it with the sheet protected.
    Last edited by Master Foo; 07-03-2013 at 03:22 AM. Reason: Found issue when sheet locked

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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