excel两个selectionchange事件怎么合并呢 5
PrivateSubWorksheet_SelectionChange(ByValTargetAsRange)DimrngSelAsRangeDimarrR(1To5)S...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim rngSel As Range
Dim arrR(1 To 5)
Set rngSel = Intersect(Target, [A1:A25])
If rngSel Is Nothing Then [B27].Resize(1, 5).ClearContents: Exit Sub
For Each irng In rngSel
For i = 1 To 5
arrR(i) = arrR(i) + Val(irng.Offset(0, i)) * IIf((irng.Row > 26) * (i < 6), 10, 1)
Next
Next
[B27].Resize(1, 5) = arrR
If Target.Row = 27 And Target.Column = 7 Then Target.Copy
If Target.Row = 29 And Target.Column = 7 Then Target.Copy
If Target.Row = 31 And Target.Column = 7 Then Target.Copy
If Target.Row = 33 And Target.Column = 7 Then Target.Copy
If Target.Row = 27 And Target.Column = 8 Then Target.Copy
If Target.Row = 29 And Target.Column = 8 Then Target.Copy
If Target.Row = 31 And Target.Column = 8 Then Target.Copy
If Target.Row = 33 And Target.Column = 8 Then Target.Copy
End Sub
如果Target范围是A1:A25,那下面的点击复制就不起作用了。但是这个范围不能改
第二个问题是有ClearContents:exit sub G27单元格点击复制出来的数值还是0该怎么调整。
如果方便可留下联系方式给你传附件 展开
Dim rngSel As Range
Dim arrR(1 To 5)
Set rngSel = Intersect(Target, [A1:A25])
If rngSel Is Nothing Then [B27].Resize(1, 5).ClearContents: Exit Sub
For Each irng In rngSel
For i = 1 To 5
arrR(i) = arrR(i) + Val(irng.Offset(0, i)) * IIf((irng.Row > 26) * (i < 6), 10, 1)
Next
Next
[B27].Resize(1, 5) = arrR
If Target.Row = 27 And Target.Column = 7 Then Target.Copy
If Target.Row = 29 And Target.Column = 7 Then Target.Copy
If Target.Row = 31 And Target.Column = 7 Then Target.Copy
If Target.Row = 33 And Target.Column = 7 Then Target.Copy
If Target.Row = 27 And Target.Column = 8 Then Target.Copy
If Target.Row = 29 And Target.Column = 8 Then Target.Copy
If Target.Row = 31 And Target.Column = 8 Then Target.Copy
If Target.Row = 33 And Target.Column = 8 Then Target.Copy
End Sub
如果Target范围是A1:A25,那下面的点击复制就不起作用了。但是这个范围不能改
第二个问题是有ClearContents:exit sub G27单元格点击复制出来的数值还是0该怎么调整。
如果方便可留下联系方式给你传附件 展开
2017-05-21
展开全部
把一个事件的内容 从IF开始到ENDSUB之 前剪切下来,贴到 另一个事件的ENDSUB之前,注意还是单行开头,不要重复,就该可以了
追问
OK,现在第二个问题是点击G27单元格时,第27行B27 C27 D27 E27 F27就自动清空了。。复制出来的数值还是0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询