我经常收到包含“不知道”值的单元格的工作表。我想要一个宏来轻松地删除每个单元格中的值,这些单元格是从输入“不知道”的单元格向下的两个单元格。
这是我目前的宏..你看我是一个真正的初学者:/
Sub Makro4()
'
' Delete input in cell below a cell containing "not know"
'
'
Cells.Find(What:="not know", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
On Error Resume Next
Selection.ClearContents
ActiveCell.Offset(3, 0).Select
Selection.ClearContents
Range("A1").Select
End Sub
喜欢一些支持!
答案 0 :(得分:0)
以下内容应该有所帮助
Dim i as Long, Rng as Range
Set Rng = Worksheets("Sheet1").Range("A1:A10000")
For i = 1 to 10000
if Rng.Cell(i,1).Value = "dont know" Then
Rng.Cell(i + 2, 1).ClearContents
end if
Next i
答案 1 :(得分:0)
这将有效:
Sub luxations()
Dim rBig As Range, rLittle As Range, r As Range
Set rBig = ActiveSheet.UsedRange.Cells.SpecialCells(xlCellTypeConstants)
Set rLittle = Nothing
For Each r In rBig
If r.Text = "not know" Then
If rLittle Is Nothing Then
Set rLittle = r
Else
Set rLittle = Union(r, rLittle)
End If
End If
If Not rLittle Is Nothing Then
rLittle.Offset(3, 0).Clear
End If
Next
End Sub