我不知道为什么我会在此代码中遇到1004 Runtime错误,并且可以使用一些帮助。
错误在这里发生:
rescDate = Application.WorksheetFunction.WorkDay_Intl(CloseDate, 3, 11, Holidays)
我尝试过的事情:
Option Explicit
Dim CloseDate as Date
CloseDate = GeneralInfo.Range("genCloseDate")
rescDate = Application.WorksheetFunction.WorkDay_Intl(CloseDate, 3, 11, Holidays)
AND
Option Explicit
Dim wb as workbook
Dim CloseDate as Range
Set wb=MLAChecklist 'Codename of workbook
set CloseDate = wb.GeneralInfo.Range("genCloseDate")
rescDate = Application.WorksheetFunction.WorkDay_Intl(CloseDate, 3, 11, Holidays)
单步执行代码时,无论哪种情况,我都尝试过CloseDate
变量的日期确实采用MM / DD / YYYY格式。
下面是目前的完整代码:
Option Explicit
Sub FundDateCalc()
Dim CloseDate As Range, HolidayDates As Range
Dim rescDate As Date, FundingDate as Date
Dim LoanPurp As String
Set HolidayDates = Holidays.Range("Holidays")
Set CloseDate = GeneralInfo.Range("genCloseDate")
rescDate = Application.WorksheetFunction.WorkDay_Intl(CloseDate, 3, 11, Holidays)
FundingDate = Application.WorksheetFunction.WorkDay(rescDate, 1, Holidays)
End Sub