+ Reply to Thread
Results 1 to 6 of 6

IF statement and Vlookup Query?

  1. #1
    Registered User
    Join Date
    07-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    11

    IF statement and Vlookup Query?

    Hi,

    I'm new to the forum and a definite novice compared to most on here. Anyway hope you can help with the following problem.

    I'm basically need to do a complex vlookup statment but I'm not sure if it is the correct or easiest way to do it.

    In my new spreadsheet I'm searching for a project I.D. eg. "1000".

    In the source data spreadsheet the Project I.D. is in Column 1.

    What I need to do is search the columns to the immediate right of the Project ID which have headings: "Milestone 1 Description" and "Milestone 1 Date". up to "Milestone 10 Description" and Milestone 10 Date". So 21 Columns in total including the project ID.

    What I need to do is search along the row with Project I.D "1000" until I get a description "Project Completion". If this description is in the column "Milestone 3 Description" I then want the formula to return the details in "Milestone 3 Date".

    Hope the above is clear and if so those anyone have an idea of how to do it?

    Thanks in advance.

  2. #2
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Perth, WA, Australia
    MS-Off Ver
    Office 365
    Posts
    249

    Re: IF statement and Vlookup Query?

    Hi Ross, and welcome to the forum.

    You can do this with a single statement, but I usually break a problem down into parts and use what's called a "helper column" to store intermediate results. People have different approaches to helper columns; I usually stick mine out of sight, beyond column AA somewhere.

    Using your naming, we'll have two sheets: Source and New.

    So, the first step is to find your project ID in the source data sheet. In column AB of New (New!AB:AB) I'd have a series of formulae for as many projects as you want to look up, of the form =IF($A1<>"",MATCH($A1,Source!$A:$A,0),"") (ie, enter that in New!AB1 and copy it down as far as you need to go). Pick a larger number of rows than you need: say, 100 or 1000; it will ignore any rows where nothing is entered in column A.

    Then, in the next column (New!AC:AC), we make use of that information to look across the correct row of your source for the correct column: =IF(ISNUMBER(AB1),MATCH("Project Completion",INDEX(Source!$A:$A,AB1):INDEX(Source!$U:$U,AB1),0),""). That will look for the text "Project Completion" in any of the first 21 columns. Copy this down also for as many rows as you did with the previous step.

    Now you are ready to use this information. Next to your project ID in column A, you can have the date information you wanted in column B with: =IF(ISNUMBER($AC1),INDEX(Source!$A:$U,$AB1,$AC1+1),""). This will retrieve the data information from the column next to your "Project Completion" column.

    There are more succinct ways of doing it, and I'd normally add a few bells and whistles (for example, row 1 might be a title row and you'd begin on row 2) but those are the basics and I find it helpful, especially with more tricky statements, to be able to analyse intermediate results as the final solution is being built.

  3. #3
    Valued Forum Contributor ffffloyd's Avatar
    Join Date
    05-20-2008
    Location
    Perth, WA, Australia
    MS-Off Ver
    Office 365
    Posts
    249

    Re: IF statement and Vlookup Query?

    This is not a post.
    Last edited by ffffloyd; 07-12-2011 at 10:19 PM. Reason: oops, was meant to be a new question - admin, please delete this post

  4. #4
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: IF statement and Vlookup Query?

    Hello ross carr,

    Try this,

    Assume your look up project ID "1000" is in A2,

    =INDEX('Source Sheet'!$A$1:$U$1,MATCH("Project Completion",INDEX('Source Sheet'!$A:$U,MATCH($A2,'Source Sheet'!$A:$A,0),0),0)+1)

    If your project ID is repeating this wouldn't work as expected. If so, please attach a dummy file.
    Last edited by Haseeb Avarakkan; 07-12-2011 at 11:01 PM.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  5. #5
    Registered User
    Join Date
    07-12-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2003
    Posts
    11

    Re: IF statement and Vlookup Query?

    Thanks ffffloyd and hasseb A for getting back to me so soon.

    ffffloyd - you're method worked perfectly and was especially easy for me to understand too when you broke the formula down into 3 sections.

    Hasseb A - I also tried your formula but it was returning the column heading eg. "Milestone 9 Date" and not the actual date.

    Thanks though. Gave me a great insight into how index and match can be used in relatively complex formulae.

  6. #6
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    365
    Posts
    2,243

    Re: IF statement and Vlookup Query?

    it was returning the column heading eg. "Milestone 9 Date" and not the actual date
    I thought you want to return the heading, not the date.

    Use VLOOKUP,

    Please Login or Register  to view this content.
    To avoid #N/A error,

    Please Login or Register  to view this content.
    then change the cell format >> Custom,

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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