Excel日期表与VBA的交点

时间:2018-06-22 17:01:28

标签: excel vba excel-vba

我有一个Excel页面,并且存储日期类型数据。这将记录每年的额外工作日和假期。此页面中的其他表具有开始和结束日期。我想给员工一些间隔时间。我想使用VBA。如何解决这个问题?

2 个答案:

答案 0 :(得分:1)

使用NETWORKDAYS.INTL()

=NETWORKDAYS.INTL(E2,F2,1,A2:A3)

enter image description here

答案 1 :(得分:-1)

enter image description here

这是Excel表和我的代码的图片:

Dim startDate As Date
Dim endDate As Date
Dim retValue As Integer
Dim days As Variant
Dim dates As Variant


days = Worksheets("Tényleges munkanapok").ListObjects("TáblázatKorrekciósNapok").DataBodyRange.Value
dates = Worksheets("Tényleges munkanapok").ListObjects("TáblázatSzámoló").DataBodyRange.Value


Dim i As Integer
Dim actualDate As Date

startDate = days(1, 1)
actualDate = dates(1, 1)



Dim CountVariant As Integer
CountVariant = UBound(days)
i = 0

Do While i <= CountVariant
    If startDate < actualDate Then
    i = i + 1
End If    
Loop