+ Reply to Thread
Results 1 to 8 of 8

Vlookup/if statement??? Need help before i can record a macro

  1. #1
    Registered User
    Join Date
    06-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Vlookup/if statement??? Need help before i can record a macro

    I use vlookup to bring over info from other reports. The cells in column A will represent a Stockroom as I show below. Column B will be part numbers. I want to do a vlookup that will basically say if column A equals "EEI" then search in this other worksheets table array but only for rows that have "EEI" in column A. Then it would need to repeat that same formula through the rest of the rows where the "IF" would change based on what's in column A of my new worksheet and the table array in the "other" worksheet is dependent on what's in column A of that other worksheet also.

    So basically, I know this isn't the formula which is why I need help.....

    If A7 (worksheet 1) is equal to "value" then, vlookup B7, (worksheet 2) If A7 is equal to "value" B7:B1012, 3, False. **But I need in the same formula--- If A7 (worksheet 1) is equal to "2nd value" then, vlookup B7, (worksheet 2) If A7 is equal to "2nd value" B7:B1012, 3, False.*** The "value" will change multiple times.

    Can all of this go into one formula?

    I'll be happy to provide as much detail in addition to this that's needed. I have to get this solved so I can record a macro to automate a weekly report.

    Thanks in advance!!!

  2. #2
    Registered User
    Join Date
    10-28-2012
    Location
    Poland
    MS-Off Ver
    Excel 2007/2010
    Posts
    94

    Re: Vlookup/if statement??? Need help before i can record a macro

    try with iferror
    =iferror(first vlookup;second vlookup)
    Like to say thanks ?Please use the star icon.

  3. #3
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Vlookup/if statement??? Need help before i can record a macro

    Bit unclear to me what you are after exactly. Can you create a mock file with sheets and false data to help explain please. Also can you include manually entered results which are highlight red for example so we know where the formula(s) go and we can be sure any solution given works as you expect.

    Looks like you have a grasp of the vlookup formula syntax so if you want to basically use if's to do the correct lookup follow this:

    =IF(value=this,thendothis,elsedothis)

    because you want to do multiple checks you can use more than one if:

    =IF(value=this,thendothis,IF(value=this,thendothis,IF(value=this,thendothis,elsedothis)))
    Say thanks, click *

  4. #4
    Registered User
    Join Date
    06-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Vlookup/if statement??? Need help before i can record a macro

    I'll test Young_86's response tonight. If I can't figure it out I'll supply the info needed by Harribone tonight also.

    Thanks for the very quick responses!!!

  5. #5
    Registered User
    Join Date
    06-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Vlookup/if statement??? Need help before i can record a macro

    Ok. So something I'm doing is not working out for me.

    Below are screenshots and descriptions of what I'm trying to do.

    This is my weekly report. Each week I start a new tab and import my data for the current week and leave last week's data on a separate tab.
    1.JPG

    Then I start my vlookup. In column A there is a stockroom for each part. That basically states where the part is. My vlookup is set to us B6 as the starting point so I'm searching for the part number. But I have to do a vlookup per stockroom in column A because the same part could be multiple places. I'm trying to search "table array" in the April 29th worksheet (previous week) to pull in data for columns E, F, and G. I use column D as my vlookup formula cells.
    vlookup1.JPG

    The April 29th sheet has the same info layout but it has the data I need for the blank columns above. So on this sheet I'm grabbing the data from D, E, and F.
    2.JPG

    As you can see in the images, I've made the text in column A red. That is what I need the formula to be dependent on. So and example: if A on the (may 20th) sheet is "EEI", then perform the vlookup using the info (table array) on the (april 29th) sheet but only if column A (April 29th) also is "EEI". Within the same formula I'd need to allow "EEI" to change both places to "LAB" and any other stockroom set up.

    The number of rows changes week to week based on new stock which is why I need this formula to be specific to looking at the data in column A versus selecting a specific range. I do this manually each week now by selecting each range (based on column A) individually. But I'm manually doing this. If I automate this, Excel wouldn't know where to stop if I cannot make it dependent on A.

    Let me know if this is enough info to help figure out the formula.

    Thanks again!!!!!

  6. #6
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Vlookup/if statement??? Need help before i can record a macro

    It's a bit confusing trying to depict what you what using screenshots, if you can upload a sample file (with mock data) then it may be clearer to us so we can provide a solution.

    I will have a go anyway at trying to solve your issue still:

    Lets say on May 20th sheet you are on row 6. The room is EEI (A6) and part is PART (B6 - i've used PART for ease of example). You want to use a formula in C6 which looks at April 29 to get the information when Col A = EEI and Col B = PART, if there is a match then you can return Col C. To do this you will need to join the room and part together on each sheet to create a unique identifier. So on each sheet insert a new column before col A. In A6 type =B6&C6 to create the unique identifier. Make sure you do this on each sheet.

    Now in D6 (which was C6 earlier on before the new column was inserted) on May 20 sheet type =VLOOKUP(A6,'April 29'!A6:F27,4,0). This should then fo a lookup based on room AND part number.
    The new column was inserted infront of the others because a vlookup will always look for the match in the first column. If you want to put the join column at the end instead you can but will need to use the INDEX/MATCH function to perform the search.
    Before I explain that way to you though have a go at the above to see if this does what you are looking for, just to make sure I'm on the right track.

    EDIT: Forgot to say the the formula i mention to type in A6 needs dragging down for each row.

  7. #7
    Registered User
    Join Date
    06-04-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Vlookup/if statement??? Need help before i can record a macro

    Harribone:

    Thank you, thank you, thank you!!! This worked perfectly. I'm not concerned with it being at the end. I can record the macro to delete those columns once done with calculating the vlookup. This just saved me major time that I spend each week. Was the only missing piece I could not figure out!!

    Thank you very much for the detailed response.

  8. #8
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Vlookup/if statement??? Need help before i can record a macro

    Not a problem, always glad to help!

    Thanks for the feedback :D

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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