如何從Col S中的每個單元格輸入變量「CatchPhrase」? 我需要選擇含有來自在COL每個單元值的所有行S.來自數組的進給變量
問題是,COL■找1996 diferent號碼,和col A具有628790號..的
Sub SelectManyRows()
Dim CatchPhrase As String
Dim WholeRange As String
Dim AnyCell As Object
Dim RowsToSelect As String
CatchPhrase = "10044"
'first undo any current highlighting
Selection.SpecialCells(xlCellTypeLastCell).Select
WholeRange = "A1:" & ActiveCell.Address
Range(WholeRange).Select
On Error Resume Next ' ignore errors
For Each AnyCell In Selection
If InStr(UCase$(AnyCell.Text), UCase$(CatchPhrase)) Then
If RowsToSelect <> "" Then
RowsToSelect = RowsToSelect & "," ' add group separator
End If
RowsToSelect = RowsToSelect & Trim$(Str$(AnyCell.Row)) & ":" & Trim$(Str$(AnyCell.Row))
End If
Next
On Error GoTo 0 ' clear error 'trap'
Range(RowsToSelect).Select
End Sub
例我需要:
稀釋我真的不程序員..你可以請發佈完整的腳本..我嘗試實施你的解決方案...但沒有運氣..提前感謝' –
這是完整的腳本:)什麼不適合你 – brettdj
我把你的代碼粘貼到VB中,當我啓動它時,彈出的窗口要求我運行宏。比我必須選擇運行.. :-(Sheet2.GemEm或Shee2.GemEm2 ..我應該怎麼做...? –