|
- Sub 统计()
- Set d = CreateObject("scripting.dictionary")
- Application.ScreenUpdating = False
- Dim Filename, wb As Workbook, Sht As Worksheet
- Filename = Dir(ThisWorkbook.Path & "\*.xlsx")
- ActiveSheet.UsedRange.Interior.ColorIndex = 0
- Do While Filename <> ""
- If Filename <> ThisWorkbook.Name Then
- fn = ThisWorkbook.Path & "" & Filename
- Set wb = Workbooks.Open(fn)
- Set Sht = wb.Worksheets(1)
- arr = Sht.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- x = arr(i, 1) & arr(1, j)
- cl = Sht.Cells(i, j).Interior.ColorIndex
- If cl > 0 Then d(x) = cl
- Next
- Next
- wb.Close False
- End If
- Filename = Dir
- Loop
-
- Set Sht = ThisWorkbook.Sheets(1)
- arr = Sht.[a1].CurrentRegion
- For i = 2 To UBound(arr)
- For j = 2 To UBound(arr, 2)
- x = arr(i, 1) & arr(1, j)
- If d(x) > 0 Then Sht.Cells(i, j).Interior.ColorIndex = d(x)
- Next
- Next
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|