這可能會幫助你開始:
Private Sub SearchButton_Click()
Dim searchTerm As String, rng1 As Range, rng2 As Range, searchRange As Range, cl As Range
Set rng1 = Worksheets("Sheet1").Range("B1:B" & Worksheets("Sheet1").Range("B2").End(xlDown).Row)
Set rng2 = Worksheets("Sheet2").Range("B1:B" & Worksheets("Sheet2").Range("B2").End(xlDown).Row)
searchTerm = Worksheets("Sheet1").TextBox.Text
searchAndCopy rng1, searchTerm
searchAndCopy rng2, searchTerm
End Sub
Private Sub searchAndCopy(searchRange As Range, searchTerm As String)
Dim nextRow As Long
nextRow = Worksheets("Sheet3").Range("A1").End(xlDown).Row + 1
For Each cl In searchRange
If cl = searchTerm Then
cl.EntireRow.Copy Destination:=Worksheets("Sheet3").Range("A" & nextRow)
nextRow = nextRow + 1
End If
Next cl
End Sub
你嘗試過什麼了嗎?你能顯示一些代碼嗎? –