Sub 定位单元格值为0()
For Each cel In ActiveSheet.UsedRange
If cel.Value = 0 Then
End If
Next
End Sub
以上代码执行不了,求大神赐教!!
第1个回答 2018-11-23
Sub 定位单元格值为0()
Dim Rng As Range, i&, Cel As Range
For Each Cel In ActiveSheet.UsedRange
If (Not IsEmpty(Cel)) And Cel.Value = 0 Then
If i = 0 Then Set Rng = Cel: i = 1 Else Set Rng = Union(Rng, Cel): i = i + 1
End If
Next
If Not Rng Is Nothing Then Rng.Select
End Sub本回答被提问者采纳
Dim Rng As Range, i&, Cel As Range
For Each Cel In ActiveSheet.UsedRange
If (Not IsEmpty(Cel)) And Cel.Value = 0 Then
If i = 0 Then Set Rng = Cel: i = 1 Else Set Rng = Union(Rng, Cel): i = i + 1
End If
Next
If Not Rng Is Nothing Then Rng.Select
End Sub本回答被提问者采纳
第2个回答 2018-11-23
条件相符时你没有定义值
Sub 定位单元格值为0()
For Each cel In ActiveSheet.UsedRange
If cel.Value = 0 Then
MsgBox (cel.Address)
End If
Next
End Sub追问
Sub 定位单元格值为0()
For Each cel In ActiveSheet.UsedRange
If cel.Value = 0 Then
MsgBox (cel.Address)
End If
Next
End Sub追问
我的意思定位所有0值的单元格,不是获取单元格地址哦。
追答不是定位到了么?给地址就是表明能定位到,并且通过FOR EACH全部循环到了。你想怎么定位?
本回答被网友采纳