新的一天,新的问题。我得到了很多帮助,希望你也能帮助我。已经四处寻找我的问题的解决方案,但没有找到。
这是我的代码:
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
并写出来:
For i = 1 To nS - 1
Sheets("DataSheet").Select
Sheets("raw_list").Rows(arrStart(i)).Copy
Cells(i, 1).Select
ActiveSheet.Paste
Next
如您所见,我在列中寻找字符串。当我得到结果时,行号存储在一个数组中。在下一个代码片段中,我在整行中写出命中。是否有可能不是取整行,而是选择要以简单的方式复制该行中的哪些列?
感谢帮助