工作表事件,代码如下:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 And Target.Row <= 9 And Target.Column = 9 Then
Range("a1").Value = Target.Value
End If
End Sub
对照图:
Range("a1") = ActiveCell
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Intersect(Range("i1:i9"), Target) Is Nothing Then
Range("a1") = ""
Else
Range("a1") = Target
End If
End Sub
Sub a()
Dim i
For i = 1 To 9
If ActiveCell = Range("I" & i) Then
Range("a1") = Range("I" & i).Value
End If
Next i
End Sub