Calculate number of workdays since a date

BravoBravoAu

Board Regular
Joined
Nov 8, 2011
Messages
64
Office Version
  1. 2016
Platform
  1. Windows
Hi experts - I'm looking for a macro to calculate the number of work days since a date (when a document was signed). Below is columns F and G from the workbook.

[TABLE="width: 500"]
<tbody>[TR]
[TD]Document signed date[/TD]
[TD]Workdays since[/TD]
[/TR]
[TR]
[TD]01-January-2018[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]15-February-2018[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Now, I know that this can be fairly easily done with a NETWORK days formula, but here is the kicker, I want to be able to assign the macro to a shape at the top of the column (located in the header of column G) so that the 'workdays since' (G2) calculates the workdays between 01-January-2018 (F2) and todays date, when the cell is selected and the macro button is pressed.

Obviously if there are ten dates listed (F2:F11) that I want calculated in the corresponding 'workdays since' column (G2:G11), this would be identified by G2:G11 being selected and the macro button pressed.

Help!! Thanks in advance.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
See if this works for you:
Code:
Sub Test()
    Dim cll As Range
    For Each cll In Selection
        If Left(cll.Address, 2) = "$G" Then
            If IsDate(cll.Offset(, -1)) Then cll = WorksheetFunction.NetworkDays(cll.Offset(, -1), Date)
        End If
    Next cll
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,270
Members
452,628
Latest member
dd2

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