基于另一个单元格值清除单元格 [英] Clear Cells based on another cell value
问题描述
大家好!我已经搜索过并试过但是无法搞清楚。
Hello everyone! I have searched and tried but cannot figure out.
我有一张桌子,B栏:V栏,B2行:B:600,B2的总范围:V600。列Q有一个VLOOKUP,它返回#n / a或基于另一个工作表的数字。我需要能够清除单元格范围("B2:P2")和范围(R2:V2"),如果单元格在整个表格中包含#n / a
,只需单击按钮,而不是即时的。我发现的最好是这样的:
I have a table, Columns B:V, Rows B2:B:600, Total range of B2:V600. Column Q has a VLOOKUP that either returns #n/a or a number based on another sheet. I need to be able to clear cell Range("B2:P2") and Range(R2:V2") if the cell contains #n/a along the entire table with the click of a button, not in real time. Best I have found is something like this:
Sub clear_sheet
Sub clear_sheet
Dim RNG1 as Range
Dim RNG1 as Range
Dim RNG2作为范围
Dim RNG2 as Range
如果是工作表("my_work_sheet")。范围("Q2")< 1然后
If worksheets("my_work_sheet").Range("Q2") < 1 then
RNG1.clear
RNG1.clear
RNG2.clear
RNG2.clear
如果
end sub
总是返回类型不匹配,就像我尝试的所有代码一样。任何帮助表示赞赏
Always returns as type mismatch as do all code I try. Any help is appreciated
推荐答案
HI
我认为RNG1和RNG2是定义名称范围所以试试这个......
I presume that RNG1 and RNG2 are Define name range so try this ...
范围("RNG1")。清除
Range("RNG1").Clear
范围("RNG2")。清除
Range("RNG2").Clear
这篇关于基于另一个单元格值清除单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!