逐句讲解下面宏的含义Private Sub Worksheet_SelectionChange(ByVal Target As Range)Dim rr As IntegerDim rng As RangeFor rr = 1 To 39Set rng = Intersect(Target,Range("G" & rr))If Not rng Is Nothing ThenRange("H1") = Range("G" & rr).ValueEnd IfN
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 20:18:12
逐句讲解下面宏的含义Private Sub Worksheet_SelectionChange(ByVal Target As Range)Dim rr As IntegerDim rng As RangeFor rr = 1 To 39Set rng = Intersect(Target,Range("G" & rr))If Not rng Is Nothing ThenRange("H1") = Range("G" & rr).ValueEnd IfN
逐句讲解下面宏的含义
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rr As Integer
Dim rng As Range
For rr = 1 To 39
Set rng = Intersect(Target,Range("G" & rr))
If Not rng Is Nothing Then
Range("H1") = Range("G" & rr).Value
End If
Next rr
End Sub
逐句讲解下面宏的含义Private Sub Worksheet_SelectionChange(ByVal Target As Range)Dim rr As IntegerDim rng As RangeFor rr = 1 To 39Set rng = Intersect(Target,Range("G" & rr))If Not rng Is Nothing ThenRange("H1") = Range("G" & rr).ValueEnd IfN
'私有的事件过程,当工作表被选择的部分发生改变时被调用,Target中包含了改变后的区域
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rr As Integer '声明整形变量rr
Dim rng As Range '声明range对象rng
For rr = 1 To 39 '从G1到G39单元格
Set rng = Intersect(Target,Range("G" & rr)) 'rr设定为变化后的选定区域与G1到G39的交集
If Not rng Is Nothing Then '若交集为空,就是说如果G1到G39中没有包含被选定的部分
Range("H1") = Range("G" & rr).Value '则H1单元格设为该交集最下面的格子的数值
End If
Next rr
End Sub