我需要這個代碼在Sheet1通過一個表來搜索和跨符合特定標準,該行復制,VBA匹配條件並粘貼
在哪裏我錯了什麼祕訣?
Sub find_orders()
Application.ScreenUpdating = False
Dim r As Long, endRow As Long, pasteRowIndex As Long
endRow = Sheets("sheet1").Cells(Rows.Count, 2).End(xlUp).Row
pasteRowIndex = 2
For r = 2 To endRow
If Cells(r, 6) = "d" Then
Range(Cells(r, 2), Cells(r, 6)).Copy
Sheets("sheet2").Select
Range(Cells(pasteRowIndex, 2), Cells(pasteRowIndex, 6)).Select
pasteRowIndex = pasteRowIndex + 1
Sheets("sheet1").Select
End If
Next r
End Sub
嘗試限定您的範圍/單元格。 – findwindow
謝謝你們!工作了一個魅力 – AL92