Code: Select all
Sub STEP5()
Dim ws1 As Worksheet, ws2 As Worksheet
Dim wb1 As Workbook, wb2 As Workbook
Dim r2&, lr&, i&
Set wb1 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\1.xls")
Set ws1 = wb1.Worksheets.Item(1)
Set wb2 = Workbooks.Open("C:\Users\**I've been banned**\Desktop\Files\AlertCodes.xlsx")
Set ws2 = wb2.Worksheets.Item(4)
With ws1
lr = .Cells(.Rows.Count, "I").End(xlUp).Row
For i = 2 To lr
r2 = WorksheetFunction.Match(.Cells(i, "I"), ws2.[B1:B5], 0)
If ws2.Cells(r2, "D") = ">" Then
.Cells(i, "K").Value = .Cells(i, "D").Value - 0.01 * .Cells(i, "D").Value
Else
.Cells(i, "K").Value = .Cells(i, "D").Value + 0.01 * .Cells(i, "D").Value
End If
Next i
End With
End Sub
line that has errors
r2 = WorksheetFunction.Match(.Cells(i, "I"), ws2.[B1:B5], 0)
The issue is with this B1:B5
i have more data & this is not working for that