如果C列下的单元格值为“ Confirm”,我尝试添加空白行。这可能吗? 如果宏在C列下找到“确认”,我希望宏在表的最后一个活动行之前添加空白行。
致谢, Arjun T A
答案 0 :(得分:0)
已编辑。
Dim x As Long, lRow As Long
lRow = Sheet1.Cells(Rows.Count, 3).End(xlUp).Row
For x = lRow To 2 Step -1
If Cells(x, 3).Value = "Confirm" Then
With Cells(x, 3).Offset(1).EntireRow
.Insert Shift:=xlDown
.ClearFormats
End With
End If
Next x
答案 1 :(得分:0)
Option Explicit
Sub blankAfterConfirm()
Dim rng As Range, fnd As Range, addr As String
With Worksheets("sheet3").Range("C:C")
Set rng = .Find(what:="confirm", After:=.Cells(1), MatchCase:=False, _
LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, SearchFormat:=False)
If Not rng Is Nothing Then
addr = rng.Address(0, 0)
Set fnd = rng
Do
Set fnd = Union(fnd, rng)
Set rng = .FindNext(After:=rng)
Loop Until addr = rng.Address(0, 0)
fnd.Offset(1, 0).EntireRow.Insert
End If
End With
End Sub