- 帖子
- 97
- 主題
- 33
- 精華
- 0
- 積分
- 129
- 點名
- 0
- 作業系統
- Win 7
- 軟體版本
- office 2007
- 閱讀權限
- 20
- 性別
- 男
- 註冊時間
- 2019-5-7
- 最後登錄
- 2022-8-25
|
回復 3# ziv976688
加個迴圈吧- Sub 自動填色_Click()
- Application.ScreenUpdating = False
-
- Dim databook As Workbook
- Path = ThisWorkbook.Path '檔案路徑
-
- For i = 1 To Sheets(1).Range("A300").End(xlUp).Row
- Filename = Cells(i, "A").Value '檔名
- Set databook = Workbooks.Open(Path & "\" & Filename) '開啟檔案
- With databook.Sheets(1)
- .Range("BA3:BF12").Interior.ColorIndex = 15
- .Range("BA15:BF24").Interior.ColorIndex = 15
- .Range("BA27:BF36").Interior.ColorIndex = 15
- .Range("BA39:BF48").Interior.ColorIndex = 15
- .Range("BA51:BF60").Interior.ColorIndex = 15
- .Range("BA63:BF72").Interior.ColorIndex = 15
- .Range("BA75:BF84").Interior.ColorIndex = 15
- End With
- With databook.Sheets(2)
- .Range("BA3:BF12").Interior.ColorIndex = 15
- .Range("BA15:BF24").Interior.ColorIndex = 15
- .Range("BA27:BF36").Interior.ColorIndex = 15
- .Range("BA39:BF48").Interior.ColorIndex = 15
- .Range("BA51:BF60").Interior.ColorIndex = 15
- .Range("BA63:BF72").Interior.ColorIndex = 15
- .Range("BA75:BF84").Interior.ColorIndex = 15
- End With
- databook.Save '儲存
- databook.Close '關閉
- Next
-
- Application.ScreenUpdating = True
- End Sub
複製代碼 |
|