I had been trying to do matching of 2 criteria in a row on one worksheet and copy the whole row to another worksheet in the same workbook. As the loop goes on, the criteria will also increase like 1, 2 ,3 or 1A, 2A, 3A, etc. How do I use the match function so that when it is matched, it copy the whole row.
- Find 1st criteria, if matched, find next criteria. 2nd, 3rd criteria is in different colum but same row.
- If 2nd criteria does not matched, look for next row with matched 1st criteria in different row
- If both criteria matched, whole row is copy and paste to another worksheet
- Criteria increased and match function start to find new matched criteria
I had been trying on this code but doesn't seem to work or give a lot error, instead of using INDEX, I change it to CopyEntireRow.
=INDEX($D$2:$D$10,MATCH(1,(A13=$B$2:$B$10)*(B13=$C$2:$C$10),0))
I need some helps or advice for a better way to improve this method. Thanks!
1 criteria code
Private Sub CommandButton1_Click()
Dim strLastRow As String
Dim rngC As Range
Dim strToFind As String, FirstAddress As String
Dim wSht As Worksheet
Dim rngtest As String
Application.ScreenUpdating = False
Set wSht = Worksheets("Data")
With wSht.Range("BM1:BM5000")
Set rngC = .Find(What:="PVC/", lookat:=xlPart)
If Not rngC Is Nothing Then
FirstAddress = rngC.Address
Do
strLastRow = Sheets("Cable List").Range("BJ" & Rows.Count).End(xlUp).Row + 1
rngC.EntireRow.Copy
Sheets("Cable List").Cells(strLastRow, 1).PasteSpecial xlPasteValues
Application.CutCopyMode = False
Set rngC = .FindNext(rngC)
Loop While Not rngC Is Nothing And rngC.Address <> FirstAddress
End If
End With
The code above find "PVC/" string in one worksheet "Data" and all matched row with the string inside will be copy to "Cable_List" worsksheet.
CopyEntrireRow
? Is it a sub/function you wrote? - yu_ominae