abcdef

随便记录下

 

Sub loaddata()

    Excel.Application.DisplayAlerts = False
    Excel.Application.ScreenUpdating = False
    
    Dim path, filename, self As String
    Dim mainwb As Workbook
    
    path = Excel.ThisWorkbook.path & "\*.xls"
    
    self = Excel.ActiveWorkbook.Name
    
    Set mainwb = Excel.ActiveWorkbook
    filename = Dir(path)
    Do While filename <> ""
        If filename <> self Then
        
            Dim wb As Excel.Workbook
            Set wb = Excel.Workbooks.Open(Excel.ThisWorkbook.path & "\" & filename)
            
            wb.Sheets.Copy after:=mainwb.Sheets(mainwb.Sheets.Count)
            
            wb.Close
        End If
        filename = Dir
    Loop
    
    
    Excel.Application.DisplayAlerts = True
    Excel.Application.ScreenUpdating = True

End Sub

 

posted @ 2020-06-18 16:01  jianc  阅读(166)  评论(0编辑  收藏  举报