-1

我创建了一个数组并给了 1 到 12 个值。我这样做是为了稍后循环使用每个名称的一部分代码。出于某种原因,我的第一个数组填充行出现错误:“需要对象”。有任何想法吗?这段代码的其余部分也有意义吗?

                Dim sArray() As String
                Dim row As Long
                Dim i As Long
                Dim arrTot() As Long
                Dim arrLate() As Long

          'Error here
                Set sArray(1) = "AAA CANADA INC."
                Set sArray(2) = "AEROTEK ULC"
                Set sArray(3) = "AKKA GROUPE AMERIQUE DU NORD INC."
                Set sArray(4) = "ALTITUDE AEROSPACE INC."
                Set sArray(5) = "ASSYSTEM CANADA"
                Set sArray(6) = "BERLETEX AERO DESIGN"
                Set sArray(7) = "MSB DESIGN INC."
                Set sArray(8) = "NORAMTEC CONSULTANTS INC."
                Set sArray(9) = "SATYAM COMPUTER SERVICES LTD."
                Set sArray(10) = "T.E.S. CONTRACT SERVICES INC."
                Set sArray(11) = "TATA CONSULTANCY SERVICES CANADA IN"
                Set sArray(12) = "TDM TECHNICAL SERVICES"

                Set vendor = Range("P2:P" & lr)
                row = 1
                For Each cell In invoicedates
                    For i = 1 To 12
                        If tbl1(row, 16) = sArray(i) Then
                            arrTot(i) = arrTot(i) + 1
                            duedate = cell.Value + 60
                            If Date > duedate Then
                                arrLate(i) = arrLate(i) + 1
                            End If
                        End If
                    Next
                    row = row + 1
                Next
4

1 回答 1

1

两件事:首先你需要重新调整你的数组:

ReDim sArray(1 To 12)

此外,在将值分配给数组之前没有“设置”。

于 2013-07-30T20:41:42.063 回答