Thought it would be as simple as, but somewhere i am wrong please help! So I am trying to find the values from rng1 in rng2 and have the output next to rng1
Thanks in advance
Sub FindValuestest() Dim wb As Workbook, wks1, wks2 As Worksheet, rng1, rng2 As Range Dim lRow1, lRow2 As Long Dim v, n, r As Variant On Error Resume Next Set wb = ThisWorkbook Set wks1 = wb.Worksheets("FEPR") Set wks2 = wb.Worksheets("EQUIP") lRow1 = wks1.Cells(wks1.Rows.Count, "B").End(xlUp).Row lRow2 = wks2.Cells(wks2.Rows.Count, "A").End(xlUp).Row Set rng1 = wks1.Range("B2", Cells(Rows.Count, "B").End(xlUp)) Set rng2 = wks2.Range("A1", Cells(Rows.Count, "A").End(xlUp)) lRow1 = lRow1 - 1 For v = 1 To lRow1 For n = 1 To lRow1 If n = rng2.Find(n, , xlValues, xlWhole, , , False) And rng2.Cells(n, 2) = "Commodity Tracking Bag Scanner" Then 'Debug.Print n rng1.Cells(n, 2) = rng1.Cells(n) & " Scanner OK" End If Next Next For v = 1 To lRow1 For n = 1 To lRow1 If n = rng2.Find(n, , xlValues, xlWhole, , , False) And rng2.Cells(, 2) = "Radio" Then rng1.Cells(n, 3) = rng1.Cells(n) & " Radio OK" End If Next Next End Sub
https://stackoverflow.com/questions/66996037/hi-all-i-could-use-some-help-with-excel-vba-trying-to-find-range-of-values-in April 08, 2021 at 09:06AM
没有评论:
发表评论