Calculate number of workdays since a date

BravoBravoAu

Board Regular
Joined
Nov 8, 2011
Messages
63
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.

Document signed dateWorkdays since
01-January-2018
15-February-2018

<tbody>
</tbody>

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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,215,054
Messages
6,122,893
Members
449,097
Latest member
dbomb1414

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