|
>A1とC5で実行したい場合
SelectionChange イベントを絡めた方法で・・
Private MyVal As Double
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
If .Count > 1 Then Exit Sub
Select Case .Address
Case "$A$1", "$C$5"
Case Else: Exit Sub
End Select
If IsEmpty(.Value) Then Exit Sub
If Not IsNumeric(.Value) Then Exit Sub
MyVal = .Value
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Count > 1 Then Exit Sub
Select Case .Address
Case "$A$1", "$C$5"
Case Else: Exit Sub
End Select
If IsEmpty(.Value) Then Exit Sub
If Not IsNumeric(.Value) Then Exit Sub
Application.EnableEvents = False
.Value = MyVal + .Value
End With
Application.EnableEvents = True
End Sub
|
|