I am attempting to have sheet1, whose content changes daily, lookup and return a value from sheet2. This value has 4 possible variations. Depending on the value returned I want to assign the character 'X' to one of four columns in sheet1 which represents department responsibility. I am getting a 'Run-time error 424: Object Required' on the line marked in red. I have not coded the assignment of the 'X' as I am working at getting things to work incrementally as my knowledge of VBA is limited. If there is a better way to accomplish this feel free to let me know. Thanks.
Sub SKU_Location()
Dim loc As String
Dim lastrow As Integer
Dim x As Variant
lastrow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
For Each x In Range("D2:D" & lastrow)
loc = Application.WorksheetFunction.VLookup(D2, List.[A2:A1000], 2, False)
If loc = "CSI002" Then
MsgBox (loc)
ElseIf loc = "CSI003" Then
MsgBox (loc)
ElseIf loc = "CSI004" Then
MsgBox (loc)
ElseIf loc = "CSI005" Then
MsgBox (loc)
End If
Next
End Sub
Bookmarks