+ Reply to Thread
Results 1 to 8 of 8

using vlookup in VBA

  1. #1
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    using vlookup in VBA

    Hello,

    I am a novice in VBA and trying to solve a problem in excel using VBA. Any hints or suggestions would be very helpful.

    I have two sheets in a workbook. One sheet (Database) has the database of products, time and costs. Cost is a function of time and product names.
    Second sheet (Sheet 2) is which a user wants to calculate cost of a particular combination of product and time. The user can put 3 product names or 4 product names, so number of rows are variable in this sheet. He will also input the time for each product.

    What I need is: to find the product (from sheet 2 as provided by the user) in the sheet 1(database) and replace the time with the time value provided by the user. Based on it, I need to bring back the corresponding cost to sheet 2.

    The sheet 2 can have same products with different time.

    I am wondering if anyone can help me on this. Any kind of hints would be helpful.

    Thanks

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

    Re: using vlookup in VBA

    Can you attach a file? To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

  3. #3
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: using vlookup in VBA

    Please find the attached.
    Attached Files Attached Files

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

    Re: using vlookup in VBA

    A simple formula
    B2 and drag it down

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: using vlookup in VBA

    Hello,

    Thanks, but :

    the Input_by_user sheet has several product "A" with different time. To calculate cost I need to loop all the different values of Time of Product A, in Database sheet and then copy the Cost from Database sheet to Input_by_User sheet.

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

    Re: using vlookup in VBA

    You only have one product called A in sheet database (A2) and you want to return in this sheet.

  7. #7
    Registered User
    Join Date
    08-21-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: using vlookup in VBA

    The Time in Database sheet will depend on the value of Time in Input_by_user sheet.
    The function to calculate cost is fixed, which is here a function of time and product, as in Database sheet.

    So the user can calculate cost of Product A with different time. Thats why I was thinking if you can give me any hint of how to use vlookup in loop in vba. Or any other way to do this.

    Thanks

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

    Re: using vlookup in VBA

    I do not understand.
    Do you want to return the time column?
    If the lookup value is column A of sheet Input_by_user and the return is column A of sheet database from column B of sheet Input_by_user.
    You can add another Vlookup on column C of Input_by_user from column A of sheet database

+ 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] 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
  2. 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
  3. 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
  4. Replies: 5
    Last Post: 07-29-2009, 07:53 AM
  5. [SOLVED] vlookup function-Can vlookup command find the data from the 5 sheets.
    By Rishab shah in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM

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