如果一個單元格包含QA1
,您想清除整列的內容嗎?
Sub Test()
Dim rCell As Range
With ThisWorkbook.Worksheets("Sheet1").Columns(4)
Set rCell = .Find("QA1", LookIn:=xlValues)
If Not rCell Is Nothing Then
.ClearContents
End If
End With
End Sub
如果你只想明確各自在列d的QA1
實例:
Sub Test()
Dim rCell As Range
With ThisWorkbook.Worksheets("Sheet1").Columns(4)
Set rCell = .Find("QA1", LookIn:=xlValues)
If Not rCell Is Nothing Then
Do
rCell.ClearContents
Set rCell = .FindNext(rCell)
Loop While Not rCell Is Nothing
End If
End With
End Sub
是否可以寫在整個工作表的外觀和刪除QA1 究竟在哪兒發現?
上薄片的QA1
所有實例:
Sub Test()
Dim rCell As Range
With ThisWorkbook.Worksheets("Sheet1").Cells
Set rCell = .Find("QA1", LookIn:=xlValues)
If Not rCell Is Nothing Then
Do
rCell.ClearContents
Set rCell = .FindNext(rCell)
Loop While Not rCell Is Nothing
End If
End With
End Sub
編輯:添加LookAt:=xlWhole
到Find
參數,以便它不刪除包含QA1和其他的文本(例如QA11
或Some text QA1
)細胞
您是否試過對示例代碼的任何修改?你認爲每條線都在做什麼? – nekomatic