我有一个约有5万行的excel工作表,我需要一个宏来搜索该工作表中的单元格,如果找到它可以将整行复制到另一个工作表中,我的问题是关键字可能在多行因此,如果有4个带有该关键字的单元格,我需要它复制所有4行并将其粘贴到另一张纸上
Sub saca()
Dim intPasteRow As Integer
intPasteRow = 2
Dim ceva As Range
Dim FirstAddress As String
Dim intRow As Integer
Sheets("Sheet2").Select
Columns("A:AV").Select
On Error Resume Next
Set ceva = Selection.Find(What:="m762",After:=activeCell,LookIn:= _
xlFormulas,LookAt:=xlWhole,SearchOrder:=xlByRows,SearchDirection:= _
xlNext,MatchCase:=True,SearchFormat:=True).activate
If Not ceva Is Nothing Then
FirstAddress = ceva.Address
Do
Set ceva = Selection.FindNext(ceva).activate
Loop While Not ceva Is Nothing And ceva.Address <> FirstAddress
End If
intRow = activeCell.Row
Rows(intRow & ":" & intRow).Select
Selection.Copy
Sheets("Sheet1").Select
activeSheet.Paste
End Sub
到目前为止,它在Sheet2中搜索“ m762”,但是它仅复制带有“ m762”单元格的第一行,而不是选择所有的行...我找不到一种方法来使它选择所有带有“ m762”的行m762”