如果某个单元格包含特定文本,我在尝试查找 VBA 代码以删除多个特定单元格时遇到了一些麻烦。此电子表格也可以运行接近 100k 行,但会因数据拉取而异。
特定的 VBA 将能够执行以下操作:
如果单元格 J3 等于 #N/A、空白或 0,则清除单元格 J3:K3 和 P3:X3 的内容,然后重复直到到达 J 列的底部。
提前致谢
最佳答案
How to clear contents for specified cells when another cell contains specific text or string
Dim cellToClear As Range
Dim cellToCheck As Range
Dim specificText As String
If cellToCheck.Value = specificText Then cellToClear.ClearContents
"I'm having some trouble trying to find VBA code "
这些链接包含 VBA 代码,您可以在尝试不再遇到问题时使用这些代码。它们包含您可以粘贴到项目中并根据需要进行修改的示例。
This link has examples of how to read the contents of a cell .
范围是工作表中的一组一个或多个单元格。您可以对范围执行操作,它将影响范围内的所有单元格。 This link has examples of how to work with a range .
循环是程序重复相同的步骤序列时,通常直到满足特定条件。 You can find examples of different loops here .
关于Excel VBA : How to clear contents for specified cells when another cell contains specific text or string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58210572/