+ Reply to Thread
Results 1 to 9 of 9

Return the Value Based on Two Columns

  1. #1
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Return the Value Based on Two Columns

    Hi,
    I need a vba code to return the value if two column's values are in sheet1 matching into sheet2,

    Let us assume that, I have two sheets in a workbook(Sheet1 and Sheet2), In Sheet1, Col A and B are there some value and same like in Sheet2(Additionally Result in Col C)
    I want to return the value in Col C of Sheet1(till A2 to last used rows) from Sheet2(Col C), if the first two column's values are matching with both sheets.

    I have attached a sample workbook. Any help would be greatly appreciated!

    Thanks,
    Chinraj
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Return the Value Based on Two Columns

    In sheet1 c2 and drag it down
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Return the Value Based on Two Columns

    Thank you very much for the formula. It works perfectly.
    Then, How to convert this into VBA script. Bcoz, I need to put this till last used rows of Col A.
    Any idea Please!!

    Thanks,
    Chinraj

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Return the Value Based on Two Columns

    The formula works the same way as a code, but if you want a code:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Return the Value Based on Two Columns

    Thank you again for the code. Its working fine for very small number of rows.
    I have few hundreds of rows in my sheet. When I apply this code to run, it is taking too long time to get result.
    What would be the cause. How can I overcome this issue. Or any loop statement code are there in VBA?

    Please advise. Thanks,

    Regards,
    Chinraj
    Last edited by chinraj; 02-24-2014 at 08:17 AM.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Return the Value Based on Two Columns

    Faster code.

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Return the Value Based on Two Columns

    Regret to inconvenience caused.
    Still I'm getting the same issue(Slow operation). I think the issue is not in above code. I put your reply(#2) formula in C2 and fill down to C1000 manually, even that time, I was getting the same issue.

    Please help me. Thank you again.

    - Chinraj -

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Return the Value Based on Two Columns

    Built-in formulas are faster than a code. The code itself does not loop, it should also be faster, so I do not know what kind of data you are working on.
    If there are data in adjacent column, The auto fill should auto, not manually
    Are your data imported from outside source? Are they imported from a website, or accounting application, such as SAP or Oracle? If so, the data are the issue?

  9. #9
    Registered User
    Join Date
    02-27-2012
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    77

    Re: Return the Value Based on Two Columns

    Quote Originally Posted by AB33 View Post
    Built-in formulas are faster than a code. The code itself does not loop, it should also be faster, so I do not know what kind of data you are working on.
    I got resolved after some modification of code. Thank you very much for your all prompt responses and its much appreciated.

+ 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] Return cell value based on criteria of 2 columns
    By Fatnslow in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-03-2012, 04:52 AM
  2. Lookup 2 columns and return value based on another 2 columns
    By rlsublime in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2012, 11:16 AM
  3. Return results based on rows and columns.
    By Darreno in forum Excel General
    Replies: 3
    Last Post: 10-12-2010, 03:55 PM
  4. return a value based on condition in 2 columns
    By ShyGuy in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-22-2008, 03:28 PM
  5. Return value based on certain criteria in multiple columns
    By kilaalaa in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-03-2005, 11:51 AM

Tags for this Thread

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