excel汇总表如何自动获取同一文件夹下不同工作簿中(工作表内容完全相同)的相同数据

2025-03-27 08:00:05
推荐回答(1个)
回答1:

只能用VBA来完成,提高悬赏分,在下面补全代码即可!

Private Sub CommandButton1_Click()
    Dim strA As String, wb As Workbook, i As Long, n As Long
    strA = Dir(ThisWorkbook.Path & "\*.xls")
    
    Do While strA <> ""
        For Each wb In Workbooks
            If wb.Name = strA Then GoTo wbnext
        Next
        Set wb = Workbooks.Open(ThisWorkbook.Path & "\" & strA)
wbnext:
               
           '处理数据
           ???
           '处理数据完成

strADo:
        wb.Close True
        strA = Dir
    Loop
    
End Sub