|
あー・・ちょっと先のコードはおかしいので、全体を↓に差し替えて下さい。
Private MyVal1 As Double, MyVal2 As Double
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
If .Count > 1 Then Exit Sub
If Not IsNumeric(.Value) Then Exit Sub
Select Case .Address
Case "$A$1": MyVal1 = .Value
Case "$C$5": MyVal2 = .Value
End Select
End With
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
With Target
If .Count > 1 Then Exit Sub
If IsEmpty(.Value) Then Exit Sub
If Not IsNumeric(.Value) Then Exit Sub
Application.EnableEvents = False
Select Case .Address
Case "$A$1": .Value = MyVal1 + .Value
Case "$C$5": .Value = MyVal2 + .Value
End Select
End With
Application.EnableEvents = True
End Sub
1つの変数で済ませるのは、無理があることが分かりました。
|
|