0

我的工作表如下面的详细信息,我想找到单词“CN-1”并使用该单词连续选择所有行。

22-005538       ERQXR01200  CN-1    2
22-005538       ERQXR01200  CN-1    2
22-005692       ERQXR01134  CN-1    2
22-005692       ERQXR01134  CN-1    2


77-055988   28  BAXR148314AC    PC-1    3
11-141773   28  BAXR148214AE    PC-1    4
45-167899   28  HAXR148214AE    PC-1    4
77-056293   28  BAXR14#218AE    PC-1    4
77-056293   28  BAXR14#238AE    PC-1    4
1076-76290415   25  HAWR14#112GQ    PC-1    2
11-141774   28  BAXR148238AE    PC-1    4
11-141779   28  BAXR148314AC    PC-1    3
4

1 回答 1

0

试试这个代码,

Sub temp()
Dim startRa As Range
Dim endRa As Range

Range("A1").Select
Cells.Find(What:="CN-1", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
Set startRa = ActiveCell

Do
    Set endRa = ActiveCell
    Cells.Find(What:="CN-1", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
            :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
            False, SearchFormat:=False).Activate
Loop While ActiveCell.Row = endRa.Row + 1

Rows(startRa.Row & ":" & endRa.Row).Select
End Sub
于 2012-11-23T13:44:26.847 回答