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'.
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'.
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
That works Perfectly. Thank you.
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
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks