3个回答
展开全部
Sub 合并单元格自动求和()
Application.ScreenUpdating = False
j = Range("F" & Rows.Count).End(3).Row
Range("G3:G" & j).UnMerge
Range("G3:G" & j).ClearContents
n = Range("F3")
m = 3
For i = 4 To j
If Range("B" & i) = "" Then
n = n + Range("F" & i)
Else
Range("G" & i - 1) = IIf(n = 0, "", n)
If m < i - 1 Then Range("G" & m & ":G" & i - 1).Merge
n = Range("F" & i)
m = i
End If
Next
Range("G" & i - 1) = IIf(n = 0, "", n)
If m < i - 1 Then Range("G" & m & ":G" & i - 1).Merge
Application.ScreenUpdating = True
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询