|
' ThisWorkbookモジュール
Option Explicit
Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
Call test(Sh)
End Sub
' 標準モジュール
Option Explicit
Dim Dic1 As Object ' Scripting.Dictionary
Function CellColor(Value, ColorIndex)
CellColor = Value
If Dic1 Is Nothing Then
Set Dic1 = CreateObject("Scripting.Dictionary")
End If
If Dic1.Exists(Application.Caller.Address(External:=True)) Then
Dic1.Item(Application.Caller.Address(External:=True)) = ColorIndex
Else
Dic1.Add Application.Caller.Address(External:=True), ColorIndex
End If
End Function
Sub test(Sh) 'マクロ一覧に出さないために引数を付加
Dim Address As Variant
For Each Address In Dic1.Keys
Range(Address).Interior.ColorIndex = Dic1.Item(Address)
Dic1.Remove Address
Next Address
End Sub
|
|