我有一个约有5万行的excel工作表,我需要一个宏来搜索该工作表中的单元格,如果找到它可以将整行复制到另一个工作表中,我的问题是关键字可能在多行因此,如果有4个带有该关键字的单元格,我需要它复制所有4行并将其粘贴到另一张纸上
Dim intPasteRow As Integer
intPasteRow = 2
Sheets("Sheet2").Select
Columns("A:AV").Select
On Error Resume Next
Selection.Find(What:="m12", After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=True, SearchFormat:=True).Activate
If Err.Number = 91 Then
MsgBox "ERROR: 'Keyword' could not be found."
Sheets("Sheet1").Select
End
End If
Dim intRow As Integer
intRow = ActiveCell.Row
Rows(intRow & ":" & intRow).Select
Selection.Copy
Sheets("Sheet1").Select
ActiveSheet.Paste
End Sub
Sub saci()
Dim rng As Range
Set rng = Range(ActiveCell, ActiveCell.Offset(10000, 0))
rng.EntireRow.Select
With Selection.EntireRow
.Cut
.Offset(.Rows.Count + 1).Insert
.Select
End With
Range("A4").Select
End Sub
到目前为止,它在Sheet2中找到第一个“ m12”单元格并将整个行复制到Sheet1,如何使它在找到“ m12”后继续搜索并复制其中所有带有“ m12”的行,而不仅仅是第一个?