1

假设您有一个产品列表(列A),旁边有总计。如果您想找到任何B等于零的总数(列)并放在LOW它旁边的单元格(列C)中,请执行以下操作:

Set Rng = Range("B1:B16").Find(What:="0", LookAt:=xlWhole, LookIn:=xlValues)
Rng.Offset(, 1).Value = "LOW"

Sub MyOffset()
    With Range("B1:B16")
        Set Rng = .Find(What:="0", LookAt:=xlWhole, LookIn:=xlValues)
        If Not Rng Is Nothing Then
            firstAddress = Rng.Address
            Do
                Rng.Offset(, 1).Value = "LOW"
                Set Rng = .FindNext(Rng)
                Loop While Not Rng Is Nothing And Rng.Address <> firstAddress
        End If
    End With
End Sub
4

1 回答 1

1

Find()方法在匹配其参数中指定的条件(“What”,“LookIn”,“LookAt”,...)时查找它被调用的范围内的单元格,并返回找到的单元格引用(一个Range对象)或Nothing如果未找到匹配项,则为空引用对象(使用关键字引用)

于 2016-09-04T13:18:12.120 回答