+ Reply to Thread
Results 1 to 2 of 2

If - For - Vlookup working together

  1. #1
    Registered User
    Join Date
    05-31-2006
    Posts
    58

    If - For - Vlookup working together

    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
    Last edited by Apel; 10-17-2006 at 11:17 AM.

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    I would use the find method rather than vlookup...If you don't work it out PM me and I will modifiy you code.
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1