Time sheet

rooster05

New Member
Joined
Mar 4, 2017
Messages
34
Hello forum

i have question which hopefully will have a quick solution
i have a time sheet for the month, this is split into up to 5 weeks starting in B6 (5 columns per week). What i would like is a macro to populate the only the weekdays of the month, however if for example 01 March 19 is Friday i would like this date to be in F6 and cells B6:E6 blank

would this be possible

thanks in advance
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
With a date in A1 (must be the first of the month), to get the start column and end column for the month :
Code:
Dim dte As Date, startColumn%, endColumn%
dte = [A1]
With WorksheetFunction
    startColumn = Weekday(.WorkDay(dte - 1, 1))
    endColumn = .NetworkDays(dte, .EoMonth(dte, 0)) + startColumn - 1
End With
 
Upvote 0
To put the dates in the appropriate columns in B6:Z6 :
Code:
Dim dte As Date, startColumn%, endColumn%
[B6:Z6].ClearContents
With WorksheetFunction
    dte = .EoMonth([A1], -1) + 1
    startColumn = Weekday(.WorkDay(dte - 1, 1))
    endColumn = .NetworkDays(dte, .EoMonth(dte, 0)) + startColumn - 1
    Cells(6, startColumn) = .EoMonth(dte, -1) + 1 + .Choose(.Weekday(.EoMonth(dte, -1) + 1, 2), 0, 0, 0, 0, 0, 2, 1)
End With
Cells(6, startColumn).AutoFill Destination:=Cells(6, startColumn).Resize(, endColumn - startColumn + 1), Type:=xlFillWeekdays
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

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