|    | 
     ' ThisWorkbookモジュール 
Option Explicit 
 
Private Sub Workbook_SheetCalculate(ByVal Sh As Object) 
  Call test2(Sh) 
End Sub 
 
' 標準モジュール 
Option Explicit 
Dim Dic1 As Object ' Scripting.Dictionary 
 
Function InteriorColor(Value) 
  InteriorColor = Value 
  test1 Array("Interior.Color", RGB(0, 255, 0)) 
End Function 
 
Sub test1(arg) 
  If Dic1 Is Nothing Then 
    Set Dic1 = CreateObject("Scripting.Dictionary") 
  End If 
  If Dic1.Exists(Application.ThisCell.Address(External:=True)) Then 
    Dic1.Item(Application.ThisCell.Address(External:=True)) = arg 
  Else 
    Dic1.Add Application.ThisCell.Address(External:=True), arg 
  End If 
End Sub 
 
Sub test2(Sh) 'マクロ一覧に出さないために引数を付加 
Dim Address As Variant 
  For Each Address In Dic1.Keys 
    Select Case Dic1.Item(Address)(0) 
      Case "Interior.Color" 
        Range(Address).Interior.Color = Dic1.Item(Address)(1) 
    End Select 
    Dic1.Remove Address 
  Next Address 
End Sub 
 
これで、当該の関数を実行しているセルの背景色を変更できます。 
 
いびきかいてないで返事してよね。 
 | 
     
    
   |