in tab 1 named (Not on a Category) column D (Vendors) is a list of random vendors. In tab 3 named (Vendor Policies) column A is a list of every vendor. Any vendors in the Not on a Category tab that matches the vendors in the Vendor Policy and has a yes in column J Write TT in column H of the Not on a Category Tab....macro bombs out everytime i run it...
[/code]
Sub testing()
Dim ws1 As Worksheet, ws3 As Worksheet
Dim lastRow1 As Long, lastRow3 As Long
Dim i As Long, j As Long
Set ws1 = ThisWorkbook.Sheets("Not on a Category")
Set ws3 = ThisWorkbook.Sheets("Vendor Policies")
lastRow1 = ws1.Cells(ws1.Rows.Count, "D").End(xlUp).Row
lastRow3 = ws3.Cells(ws3.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow1
For j = 2 To lastRow3
If ws1.Cells(i, "D").Value = ws3.Cells(j, "A").Value And ws3.Cells(j, "J").Value = "yes" Then
ws1.Cells(i, "H").Value = "TT"
Exit For
End If
Next j
Next i
End Sub
[/code]
heres the link to test
[/code]
Sub testing()
Dim ws1 As Worksheet, ws3 As Worksheet
Dim lastRow1 As Long, lastRow3 As Long
Dim i As Long, j As Long
Set ws1 = ThisWorkbook.Sheets("Not on a Category")
Set ws3 = ThisWorkbook.Sheets("Vendor Policies")
lastRow1 = ws1.Cells(ws1.Rows.Count, "D").End(xlUp).Row
lastRow3 = ws3.Cells(ws3.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow1
For j = 2 To lastRow3
If ws1.Cells(i, "D").Value = ws3.Cells(j, "A").Value And ws3.Cells(j, "J").Value = "yes" Then
ws1.Cells(i, "H").Value = "TT"
Exit For
End If
Next j
Next i
End Sub
[/code]
heres the link to test