jkluio668
12/12/2017 - 8:06 AM

按顺序打开xls

Sub open_by_list()
    arrt2 = Application.Transpose(file_arr1)
    For Each i In get_data_arr("data_6", 2) 'open order arr
        a1 = InArr2(i, arrt2, 1) 'return position or ""
        If a1 <> "" Then
            Set wb = Workbooks.Open(arrt2(a1, 1)) 'open it
        End If
    Next
End Sub
Function file_arr1() 
    Dim arrtmp1()
    MyFile = Dir(ThisWorkbook.Path & "\*.xls")
    'MsgBox MyFile
    k = 0
    Do While MyFile <> ""
        k = k + 1
        ReDim Preserve arrtmp1(1 To k)
        arrtmp1(k) = MyFile
        MyFile = Dir
        If MyFile = "" Then Exit Do
    Loop
    fill_2_filearr = arrtmp1
End Function
(Function InArr2)