- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 164
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-7-8
               
|
3#
發表於 2014-1-28 10:19
| 只看該作者
本帖最後由 Hsieh 於 2014-1-28 23:47 編輯
回復 2# leirex1201
基本上格式顏色無法使用基本功能選擇顏色
必須利用VBA輔助才能達成
Thisworkbook模組程式碼- Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
- Dim A As Range
- Application.EnableEvents = False
- With Target
- If Sh.Cells(1, .Column) = "顏色" Then
- Set A = Sheets("公司清單").[H:H].Find(Target, lookat:=xlWhole)
- If Not A Is Nothing Then _
- .Interior.ColorIndex = A.Interior.ColorIndex: .Offset(, 1) = A.Offset(, -1)
- End If
- DrowCell
- End With
- Application.EnableEvents = True
- End Sub
- Sub DrowCell()
- Dim A As Range, C As Range
- With Sheets("公司清單")
- For Each Sh In Sheets
- If Sh.Name <> .Name Then
- Set A = Sh.Rows(1).Find("所屬公司", lookat:=xlWhole)
- For Each C In Sh.Range(A.Offset(1, 0), A.End(xlDown))
- If Not .[C:C].Find(C, lookat:=xlWhole) Is Nothing Then _
- C.Interior.ColorIndex = .[C:C].Find(C, lookat:=xlWhole).Offset(, 1).Interior.ColorIndex _
- Else C.Interior.ColorIndex = xlNone
- Next
- End If
- Next
- End With
- End Sub
複製代碼
求救.rar (25.76 KB)
|
|