+ Reply to Thread
Results 1 to 8 of 8

VBA - vlookup/comparison

  1. #1
    Registered User
    Join Date
    02-28-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    25

    VBA - vlookup/comparison

    I am trying to write a macro in vba. I have sheet A with the following columns :

    Ref Id name Company Date1 x b Date2
    a 4 MMM fahdfj 12/31/12 n y 12/31/12


    I have sheet B with the following columns :

    ID Name Date1 date 2
    4 MMM 12/31/12 12/31/12
    5 ABT 12/31/12 12/31/12.

    What I want to do is Look at sheet A and read in each ID. Check this Id in Sheet B and check the date in the Date 2 column. If the Date2 in Sheet A is less than or equal to the Date 2 column in Sheet B then I want to change the Value in the Ref column of Sheet A to be "D".

    Can anybody help me with this?

    Kind Regards

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: VBA - vlookup/comparison

    Hi,

    You don't necessarily need a macro. Normal Excel functions will deliver this.

    See attached

    If you really do want a macro I'd be inclined to have the macro create this function exactly as you see it and copy it down your data as necessary.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-28-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA - vlookup/comparison

    This is just part of a much larger macro.

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA - vlookup/comparison

    Maybe:

    Please Login or Register  to view this content.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,087

    Re: VBA - vlookup/comparison

    To take Richard's suggestion, the code would be:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  6. #6
    Registered User
    Join Date
    02-28-2013
    Location
    Ireland
    MS-Off Ver
    Excel 2003
    Posts
    25

    Re: VBA - vlookup/comparison

    Thanks John,

    This worked.

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA - vlookup/comparison

    You're welcome. Glad to help out. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,087

    Re: VBA - vlookup/comparison

    Thanks for the rep.

+ 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. [SOLVED] This is my third question..I want to run vlookup to do comparison and and get it automated
    By mikail in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2013, 07:00 AM
  2. Vlookup - Comparison
    By VegasL in forum Excel General
    Replies: 1
    Last Post: 06-13-2008, 01:03 AM
  3. Vlookup - Comparison Between Tabs
    By VegasL in forum Excel General
    Replies: 2
    Last Post: 06-05-2008, 01:01 AM
  4. VLOOKUP using another table for comparison values
    By Karen S. in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-15-2006, 05:00 PM
  5. Date Comparison with VLookup
    By techiemom60 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-26-2006, 05:00 PM

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