发布时间:2019-07-30 01:30:46
请教大神,同时希望ABCJZ任意单元格发生变化,AA也能自动更新。谢谢!
表格功能符合要求,不需要另外用VB编程;
AC公式 =A1&"."&B1&"."&C1&"-"&J1 下拉 。
AA公式 =SUMIF(AC:AC,AC1,Z:Z) 下拉 。
ABCJZ任意单元格发生变化,AA、AC可自动跟随更新。
不合意请追问。
在当前工作表单的VBA对象页面,编辑如下代码即可:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row < 8 And (Target.Column < 4 Or Target.Column = 10 Or Target.Column = 26) Then
For i = 1 To 7
Cells(i, 29) = Format(Cells(i, 1), "00") & "." & Format(Cells(i, 2), "00") & "." & Format(Cells(i, 3), "00") & "-" & Format(Cells(i, 10), "000")
Next i
For i = 1 To 7
aa = 0
For j = 1 To 7
If Cells(i, 29) = Cells(j, 29) Then aa = aa + Cells(j, 26)
Next j
For j = 1 To 7
If Cells(i, 29) = Cells(j, 29) Then Cells(j, 27) = aa
Next j
Next i
End If
End Sub
vba也可以调用函数的