【说明】

B2开始到B?(中间不能有空格),定义一维数组Arr_approver()

    Dim R_sh As Worksheet
Set R_sh = ThisWorkbook.Sheets("result") approver_row = R_sh.Range("B2").End(xlDown).Row
Arr_approver = R_sh.Range("B2", Cells(approver_row, )) For k = LBound(Arr_approver) To UBound(Arr_approver)
key = Arr_approver(k, )
ifFoundRole = FindRole(key)
If ifFoundRole = "Y" Then
R_sh.Cells(k + , A_ROLE1) = Arr_Role(MAX_COUNT_ROLE - )
R_sh.Cells(k + , A_ROLE2) = Arr_Role(MAX_COUNT_ROLE - )
R_sh.Cells(k + , A_ROLE3) = Arr_Role(MAX_COUNT_ROLE - )
R_sh.Cells(k + , A_ROLE4) = Arr_Role(MAX_COUNT_ROLE)
End If
Next

例子:二维数组

从B2(左上角)到??(右下角)连续无空格的区域,声明二维数组Arr()

Public Arr

Sub Test(sheetName As String)

R = List_sh.Range("B2").End(xlDown).Row
C = List_sh.Cells(, Columns.Count).End(xlToLeft).Column Arr = List_sh.Range("B2", Cells(R, C)) a = Arr(i,j)
05-14 04:46