|
工作表区域触发事件(一个区域求相反数),一个区域除以3
Private Sub Worksheet_Change(ByVal target As Range)
On Error Resume Next
Dim rng As Range, i%
Set rng = Range(Cells(4, 20), Cells(3109, 21))
For i = 1 To 30
Set rng = Union(rng, Range(Cells(1, 20 + i * 21), Cells(3230, 20 + i * 21)))
Next
If Intersect(target, rng) Is Nothing Then Exit Sub
If Val(target) > 0 Then
Application.EnableEvents = False
target = -target
Application.EnableEvents = True
End If
Set rng = Nothing
End Sub
Private Sub Worksheet_Change(ByVal target1 As Range)
On Error Resume Next
Dim rng1 As Range, i%
Set rng1 = Range(Cells(4, 13), Cells(3109, 13))
For i = 1 To 30
Set rng1 = Union(rng1, Range(Cells(1, 13 + i * 13), Cells(3230, 13 + i * 13)))
Next
If Intersect(target1, rng1) Is Nothing Then Exit Sub
If Val(target1) > 0 Then
Application.EnableEvents = False
target1 = target1 / 3
Application.EnableEvents = True
End If
Set rng1 = Nothing
End Sub
|
|