Vba只会选择列中单元格标记为" x"

时间:2014-04-23 23:42:33

标签: excel vba

我正在寻找VBA代码,它会查看像A这样的特定列,并且只选择具有标记为" x"的某些单元格的行。

2 个答案:

答案 0 :(得分:0)

Sub SelectRow()
Dim columnRange As Range
Dim c As Range
Set columnRange = Range("A:A")

For Each c In columnRange 'For every cell in column a
    If InStr(1, c, "x") Then 'If cell contains "x" then
        c.EntireRow.Select 'Select row
    End If
Next c

End Sub

答案 1 :(得分:0)

使用

.Autofilter 方法

Sub FilterTo1Criteria()
With Sheet1
        .AutoFilterMode = False
        .Range("A:D").AutoFilter
        .Range("A:z").AutoFilter Field:=1, Criteria1:=x
End With