Reputation: 103
How I'm possible to calculate total of weekdays between two dates using Networkdays.Intl?
Currently here is my code :
.Cells(lrow, "AH").Value = Abs(WorksheetFunction.NetworkDays_Intl(.Cells(lrow, "AD"), .Cells(lrow, "T"), 1))
I'm trying to make the "=" symbol with <> but seems error. Can it be done or theres another way? Thanks! :)
Upvotes: 0
Views: 732
Reputation: 19737
You got confused with writing a formula in a cell for get the value and calling a worksheet function in VBA and just output the result in the cell.
Edit1: You usually subtract the result by 1 to get the correct count of weekdays in between dates.
For the first option, try:
.Cells(lrow, "AH").Formula = "=ABS(NETWORKDAYS.INTL(" & .Cells(lrow, "AD").Address _
& "," & .Cells(lrow, "T").Address & ",1))-1"
Above will write the formula on the cell.
For the second option:
.Cells(lrow, "AH").Value = Abs(Application.WorksheetFunction.NetworkDays_Intl( _
.Cells(lrow, "AD"), .Cells(lrow, "T"), 1)) - 1
Upvotes: 1