我声明了 5 个整数
Public Hol_1 as integer
Public Hol_2 as integer
Public Hol_3 as integer
Public Hol_4 as integer
Public Hol_5 as integer
假设我有 3 个客户端,那么我将使用 Hol_1 到 Hol_3。这也意味着: iClients = 3 我需要做的第一件事是查看我的工作表(“假期”)以确定我的 3 个客户每个人有多少假期。
Sub CountHolidays()
Dim i as integer
Dim iclients as integer
iclients = 3
For i=1 to iclients
Hol_i = WorksheetFunction.CountA(ActiveWorkbook.Sheets("Holidays").Range(Cells(2, 3 + i), Cells(50, 3 + i)))
'The worksheetfunction calculates the amount of Holiday-dates I have for each of my three clients
Next i
End sub
我收到一个编译错误,提示未定义变量:未定义 Hol_i。我尝试了 "Hol_" & i 和其他人,但无法纠正这个问题。有人有想法吗?谢谢