如果Contes = 0,则清除范围的单元格内容 [英] Clear Cell Contents of range if Contes = 0
本文介绍了如果Contes = 0,则清除范围的单元格内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想清除基于范围的单元格内容.我想我快到了.
I'm wanting to clear a cell contents of a range based. I think I'm nearly there.
Dim R As Range
Dim myRange As Range
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Set myRange = Range("Y2:Y" & LastRow)
For Each R In myRange
If R = 0 Then
cell.ClearContents
End If
Next
End Sub
感谢所有帮助.
推荐答案
问题是您的单元格引用.将 cell.
更改为 R.
R
是您要遍历的范围内的单元格,因此如果 R = 0
,清除它.
The problem is your cell reference. Change cell.
to R.
R
is the cell in the range that you are looping through so if R = 0
, clear it.
Sub clearR()
Dim R As Range
Dim myRange As Range
lastRow = Range("A" & rows.count).End(xlUp).Row
Set myRange = Range("Y2:Y" & lastRow)
For Each R In myRange
If R = 0 Then
R.ClearContents
End If
Next
End Sub
这篇关于如果Contes = 0,则清除范围的单元格内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文