+ Reply to Thread
Results 1 to 3 of 3

VLOOKUP in VBA

  1. #1
    Registered User
    Join Date
    12-08-2016
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    2

    VLOOKUP in VBA

    I have been trying to create a form and a log that work together (they are separate workbooks). So far, I have been successful in attaching a macro to radio buttons that will pull the 5 pieces of information I need from the form and input it into the log, however, each time you press one of these buttons, it creates a duplicate record in the log, just with a different end piece of information. To Clarify:

    Pressing the "NO" button pulls the ID number, the part number, the date, and the purchase order from the form, inputs it into the log, and enters "NO" into the disposition column.

    Pressing the "YES" button pulls the ID number, the part number, the date, and the purchase order from the form, inputs it into the log, and enters "YES" into the disposition column.

    Pressing the "REJECTED" button pulls the ID number, the part number, the date, and the purchase order from the form, inputs it into the log, and enters "REJECTED" into the disposition column.

    My issue with this is that I only want the second two buttons ("YES" and "REJECTED") to only adjust the disposition. I was trying to use VLOOKUP to have it find the ID number and then change the disposition, but I'm not sure how to do that across worksheets or to tell it to go several columns over and change a value once it finds the correct row.

    Any help would be greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: VLOOKUP in VBA

    A simple Find (in code) to search for the ID in a particular column of any worksheet. If found, you can simply refer to the cell offset x columns from that to update.

    For example:

    Please Login or Register  to view this content.
    But for something tailored to your workbook, upload a sample copy.

  3. #3
    Registered User
    Join Date
    12-08-2016
    Location
    Colorado
    MS-Off Ver
    2010
    Posts
    2

    Re: VLOOKUP in VBA

    So I'd be pulling the number to look for (the lookup_value?) from one work BOOK (a form) and searching for it in a DIFFERENT work BOOK (a log) and then changing the value there. This isn't sheet to sheet unfortunately.

    The form has the ID number in cell M3. So I'd want the code to look something like this

    Application.WorksheetFunction.VLOOKUP(M3[cell in form workbook],[range in log workbook A:E],2,FALSE)

    And then change the value of the cell 3 columns over in the log.

    I don't know how to tell the function to take the value from the form workbook and look for it in the log book, and then use the offset to change the value.

    I'm very new to VBA and have only gone through a couple cursory courses on it. I hope some of this makes more sense.
    Last edited by vbabeginner111; 12-08-2016 at 04:31 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 12-07-2016, 09:18 AM
  2. Replies: 0
    Last Post: 12-26-2013, 01:12 PM
  3. Display Cell within VLookup range that excel thinks matches the VLookup Value
    By headachexcelperson in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-04-2013, 04:56 PM
  4. [SOLVED] Vlookup is not working and giving =vlookup(B2,$T$2:$U$135,2,false) this kind of values.
    By yogeshsharma1981 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-09-2013, 04:08 PM
  5. how to bring all vlookup returns even with duplicate vlookup search keys
    By NYC4LIFE in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-06-2013, 04:53 PM
  6. vlookup? match? index? MULTIPLE criteria for vlookup search problem....
    By aborg88 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-11-2013, 09:56 AM
  7. Replies: 5
    Last Post: 07-29-2009, 07:53 AM

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