所有。 我在上一篇文章中找到了解决我大部分问题的解决方案。我只是需要一些帮助来扩展它。发布了以下宏(我已经为我的应用程序修改了它)在文本" CC Total"之后添加一行。出现了。我需要这个宏在" CC Total"之后添加一行。和文本" Sum Total"。如何将第二个标准添加到命令中?
Dim Col As Variant
Dim BlankRows As Long
Dim LastRow As Long
Dim R As Long
Dim StartRow As Long
Col = "A"
StartRow = 1
BlankRows = 1
LastRow = Cells(Rows.Count, Col).End(xlUp).Row
Application.ScreenUpdating = False
With ActiveSheet
For R = LastRow To StartRow + 1 Step -1
If .Cells(R, Col) = "CC Total" Then
.Cells(R + 1, Col).EntireRow.Insert Shift:=xlUp
End If
Next R
End With
Application.ScreenUpdating = True

答案 0 :(得分:0)
以下几行是关键:
If .Cells(R, Col) = "CC Total" Then
要添加额外条件,您可以执行
If .Cells(R, Col) = "CC Total" Or .Cells(R, Col) = "SUM Total" Then
或者,为了使其更易于获取更多标准:
If .Cells(R, Col) = "CC Total" Then
....
ElseIf .Cells(R, Col) = "SUM Total" Then
....
etc
End if