Networkdays Loop - 我想获得 Networkdays 循环。但给出错误。我正在使用 Office 2016。提前感谢您的努力
Networkdays Loop - I Want to get the Networkdays loop . but giving an error. I am using office 2016. appreciate your efforts in advance
i am trying networkdays loop in office 2016 but not getting through.
Sub Macro8()
Dim N As Long
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
N = Sheets("Dump").Range("A" & Rows.Count).End(xlUp).Row
Range("E1") = Date 'i want to use today's date as lastest date to find the networkdays
For i = 2 To N
Cells(i, 4).Formula = wf.NetworkDays(Cells(i, 3), Cells(1, 5))
Next N
End Sub
您的代码中的问题是未定义 i 计数器,当您关闭循环时应该是“Next i”。无需设置工作表功能
试试这个:
Sub TEST_NetworkDays()
Dim N As Long, i As Long
N = Sheets("Dump").Range("A" & Rows.count).End(xlUp).row
Range("E1") = Date 'i want to use today's date as lastest date to find the networkdays
For i = 2 To N
Cells(i, 4).Value = Application.WorksheetFunction.NetworkDays(Cells(i, 3), Cells(1, 5))
Next i
'with Holidays
For i = 2 To N
Cells(i, 4).Value = Application.WorksheetFunction.NetworkDays(Cells(i, 3), Cells(1, 5), Range(Cells(3, 9), Cells(12, 9)))
Next i
End Sub
i am trying networkdays loop in office 2016 but not getting through.
Sub Macro8()
Dim N As Long
Dim wf As WorksheetFunction
Set wf = Application.WorksheetFunction
N = Sheets("Dump").Range("A" & Rows.Count).End(xlUp).Row
Range("E1") = Date 'i want to use today's date as lastest date to find the networkdays
For i = 2 To N
Cells(i, 4).Formula = wf.NetworkDays(Cells(i, 3), Cells(1, 5))
Next N
End Sub
您的代码中的问题是未定义 i 计数器,当您关闭循环时应该是“Next i”。无需设置工作表功能
试试这个:
Sub TEST_NetworkDays()
Dim N As Long, i As Long
N = Sheets("Dump").Range("A" & Rows.count).End(xlUp).row
Range("E1") = Date 'i want to use today's date as lastest date to find the networkdays
For i = 2 To N
Cells(i, 4).Value = Application.WorksheetFunction.NetworkDays(Cells(i, 3), Cells(1, 5))
Next i
'with Holidays
For i = 2 To N
Cells(i, 4).Value = Application.WorksheetFunction.NetworkDays(Cells(i, 3), Cells(1, 5), Range(Cells(3, 9), Cells(12, 9)))
Next i
End Sub