I am building a macro which will compare dates (in date format dd/mm/yyyy hh:mm) from column AO with dates (in date format dd/mm/yyyy hh:mm) in column AL and it will print their difference in working days to the column AS (just the number of the days, not minutes etc.) I have searched and found that NETWORKDAYS is a function in excel that does that but I dont know how to implement it for a range in VBA. My code so far, is pretty similar to one I found in the web but it is for specific dates, not for a range. Any ideas? Much appreciated!
What I have so far is this, but it says there is an error in line with d1=cell.Offset... I dont now why!
Dim d1 As Range, d2 As Range, wf As WorksheetFunction
'Dim N As Long
Set wf = Application.WorksheetFunction
For Each cell In Range(Range("AT2"), Range("AT2").End(xlDown))
Set d1 = cell.Offset(0, -4)
Set d2 = cell.Offset(0, -7)
cell.Value = wf.NetworkDays(d1.Value2, d2.Value2)
Next cell
Set
ranges:Set d1 = cell.Offset(0, -4)
– Scott Craner