inserting date

paul_pearson

Board Regular
Joined
Mar 3, 2013
Messages
181
I enter a date into C4 (always a Monday).Is there a formula or VBA Code which then inserts daily dates from Monday to Friday into the following cells...C4:C8 (dates 17/6/2013 to 21/6/2013) , C12:C16 (dates 24/6/2013 to 28/6/2013) etc,,,etc,, with dates to 21/12/2013

No weekend dates required only Monday to Friday

Thanks

Paul
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Right click the bottom right corner of cell C4,drag across the cells, select fill weekdays from the dropdown list

Edit: Sorry poor reading skills.Please ignore. didn't notice the gap in the data
 
Last edited:
Upvote 0
Or with a formula. If you have the start date in C4, then in C5 use this formula and drag to copy down.
It will leave 3 empty rows between every week:
=IF(MOD(ROW()-4,8)=0,INDIRECT("C"&ROW()-4)+3,IF(MOD(ROW()-4,8)>4,"",C4+1))
 
Upvote 0
Excellent
Could this also be achieved with VBA code.Works greatr and I could use a button to insert
Thanks again
Paul
 
Upvote 0
I would use a button to insert the dates but would also need a button to delete the dates but this would need a password so as the dates cannot be deleted
Thanks again
 
Upvote 0
Would this work for you?

Code:
Sub weekday_calendar()

Dim roffset As Integer

Dim datecount As Date

roffset = 1

Cells(4, 3).Activate

If Weekday(Cells(4, 3), vbMonday) <> 1 Then
    MsgBox "Cell C4 must contain the date of a Monday"
    Exit Sub
End If

datecount = Cells(4, 3).Value

While Year(datecount) = Year(Cells(4, 3))

    If roffset > 4 Then
        
        roffset = roffset + 3
        ActiveCell.Offset(roffset).Activate
        datecount = datecount + 2
        roffset = 0
    End If
    
    datecount = datecount + 1
    
    If Year(datecount) = Year(Cells(4, 3)) Then
        ActiveCell.Offset(roffset).Value = datecount
    End If
    
    roffset = roffset + 1
    
Wend
    
    
End Sub
 
Upvote 0
Hi Galt13
.
Works great

Is it possible to add a delete button for removing the dates but with password protection so that the dates can only be deleted by me

Thanks
 
Last edited:
Upvote 0
Hi Galt13
.
Is it possible to add a delete button for removing the dates but with password protection so that the dates can only be deleted by me

Also in B4:B9 (merged cells) , B12:B17 (merged cells) etc..etc.. I have the weeknumber....could this be incorporated into the code as well....it would insert along with the dates

Thanks
 
Last edited:
Upvote 0

Forum statistics

Threads
1,221,449
Messages
6,159,933
Members
451,604
Latest member
SWahl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top