Rostricalv
Rostricalv

Reputation: 21

Excel if Function,select cell in line with match

Here is my problem .

I have an excel workbook with 2 sheets with the same fields but different amount of records. Both sheets have an ID field and date field.

If the ID from column a of sheet 2 exists in column a of sheet 1 then I want to use the date field from sheet 2 to populate the date field in sheet 1 for that matching ID.

Please help me figure this out. I can post sample data.

Thank you

Upvotes: 1

Views: 1433

Answers (1)

skkakkar
skkakkar

Reputation: 2828

As suggested by @L42 VLOOKUP can be used for your situation. A simple example mentioned below can guide you to adopt it to your situation. There are four pieces of information that you will need in order to build the VLOOKUP syntax:

The value you want to look up, also called the lookup value.

The range where the lookup value is located. Remember that the lookup value should always be in the first column in the range for VLOOKUP to work correctly. For example, if your lookup value is in cell C2 then your range should start with C.

The column number in the range that contains the return value. For example, if you specify B2: D11 as the range, you should count B as the first column, C as the second, and so on.

Optionally, you can specify TRUE if you want an approximate match or FALSE if you want an exact match of the return value. If you don't specify anything, the default value will always be TRUE or approximate match.

Now put all of the above together as follows:

=VLOOKUP(lookup value, range containing the lookup value, the column number in the range containing the return value, optionally specify TRUE for approximate match or FALSE for an exact match).

In the sample data shown in the sheet1 and sheet2. Shee2 has ID column and Date column. Formula to be put in cell B2 of Sheet1 is:

   =VLOOKUP($A2, Sheet2!$A$2:$B$6,2,0)

Fill down the formula and it will correctly pick dates from Sheet2 and fill in sheet1. Sample data screenshots are placed below.

Sheet1 Sheet2

Upvotes: 1

Related Questions