已收到帮助如何在列中搜索字符串,然后将其存储在数组中。是否可以存储整行?已搜索但找不到。
我想在一个包含字符串数据的工作表中搜索。然后将包含该字符串的那些行复制到另一个工作表。
我的代码看起来像这样。
Set wsRaw = Worksheets("raw_list")
Set phaseRange = wsRaw.Columns(PhaseCol)
SearchString = "start"
Set aCell = phaseRange.Find(What:=SearchString, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
Set bCell = aCell
ReDim Preserve arrStart(nS)
arrStart(nS) = aCell.Row
nS = nS + 1
Do While ExitLoop = False
Set aCell = phaseRange.FindNext(After:=aCell)
If Not aCell Is Nothing Then
If aCell.Row = bCell.Row Then Exit Do
ReDim Preserve arrStart(nS)
arrStart(nS) = aCell.Row
nS = nS + 1
Else
ExitLoop = True
End If
Loop
Else
End If
感谢您的帮助:)