Sub count()
Dim position As Integer
Dim start As Integer
start = 1
Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet3")
With ActiveSheet
Dim LastRowA As Long
LastRowj = .Cells(.Rows.count, "J").End(xlUp).Row
For jstart = 2 To LastRowj
For start = 2 To 303
position = InStr(1, UCase(Cells(jstart, 10).Value), .Cells(start, 17).Value)
If position > 0 Then ws1.Cells(jstart, Range("A:J")).Copy ws2.Cells(jstart, Range("A:J"))
Next start
谢谢楼上的,晚上自己也小研究了一下,问题得到解决,帮我看看
Sub count()
Dim position As Integer
Dim start, copyrow, jstart As Integer
start = 1
copyrow = 2
Dim ws1 As Worksheet: Set ws1 = ThisWorkbook.Sheets("Sheet1")
Dim ws2 As Worksheet: Set ws2 = ThisWorkbook.Sheets("Sheet3")
Dim LastRowAinsheet3 As Long
LastRowAinsheet3 = ws2.Cells(ws2.Rows.count, "A").End(xlUp).Row
MsgBox ("LastRowAinsheet" & "=" & LastRowAinsheet3)
Dim LastRowA As Long
LastRowA = ws1.Cells(ws1.Rows.count, "A").End(xlUp).Row
For jstart = 2 To LastRowA
For start = 2 To 303
position = InStr(1, UCase(ws1.Cells(jstart, 1).Value), ws1.Cells(start, 17).Value)
If position > 0 Then
ws1.Range("A" & jstart, "I" & jstart).Copy ws2.Range("A" & LastRowAinsheet3 + 1, "I" & LastRowAinsheet3 + 1)
LastRowAinsheet3 = LastRowAinsheet3 + 1
' MsgBox (ws1.Range("A" & jstart).Value)
' MsgBox ("jstart" & "=" & jstart)
Exit For
End If
Next start