'===定义函数-从表1查找字符复制到表2==
'X 是要查找的东西,
'startRow 是开始行号
' Asht 源表
'Bsht 目标表
'使用如下
'Sub ttt()
' s1 = Sheets("Sheet4").Range("c1").Value
' MsgBox "准备为您查找【" & s1 & "】的数据", 64 1, "哆哆提示"
' shtFindTosht s1, 4, Sheet1, Sheet4
'End Sub
'=====================
Sub shtFindTosht(X, startRow, Asht As Worksheet, Bsht As Worksheet)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.DisplayAlerts = False
Dim s, n, Lr, R As Range
s = X
n = startRow
Bsht.Range("a" & n & ":BB10000").Clear
On Error Resume Next
Set R = Asht.Cells.Find(s, LookAt:=xlWhole)
If Not R Is Nothing Then
firstAddress = R.Address
Do
R.EntireRow.Copy Bsht.Range("a" & n)
Set R = Asht.Cells.FindNext(R)
n = n 1
Loop While Not R Is Nothing And R.Address <> firstAddress
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.DisplayAlerts = True
End Sub