|
楼主 |
发表于 2018-6-21 20:50
|
显示全部楼层
请问下下面怎么优化代码,一有动作一点击,就无限自动添加了
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If [h2] <> "" Then
Dim i, p
i = ActiveSheet.Cells(Rows.Count, 8).End(xlUp).Row + 1
p = ActiveSheet.Cells(Rows.Count, 9).End(xlUp).Row + 1
Cells(i, 8).Value = "输入1"
Cells(i + 1, 8).Value = "输入2"
Cells(i + 2, 8).Value = "输入3"
Cells(i + 3, 8).Value = "输入4"
Cells(p, 9).Value = "添加1"
Cells(p + 1, 9).Value = "添加2"
Cells(p + 2, 9).Value = "添加3"
Cells(p + 3, 9).Value = "添加4"
End If
End Sub |
|