excel表格 代码问题
发布网友
发布时间:2022-05-16 08:01
我来回答
共3个回答
热心网友
时间:2023-10-16 01:40
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
Dim j As Integer
Dim x As Range
For Each x In Target
i = x.Row
j = x.Column
If j = 2 Then
Cells(i, 1) = Cells(i, 1) + Cells(i, 2)
End If
Next
End Sub
热心网友
时间:2023-10-16 01:40
一、A列是结果列,你要A列也输入数据再加A列原来的数?
二、如果是B列改变在A列累加,代码为
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 2 Then
Cells(Target.Row, 1) = Cells(Target.Row, 1) + Cells(Target.Row, 2)
End If
End Sub追问感觉你的简单,但是速度慢了点,还是要谢谢你 以后还会有问题的
热心网友
时间:2023-10-16 01:41
Private Sub Worksheet_Change(ByVal Target As Range)
Dim i As Long
Dim j As Integer
i = Target.Row
j = Target.Column
If j = 2 Then
Cells(i, 1) = Cells(i, 1) + Cells(i, 2)
End If
End Sub