Computing.Net > Forums > Windows Vista > Excel help: how to reference & return data...

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Excel help: how to reference & return data...

Reply to Message Icon

Name: Bear204
Date: October 27, 2009 at 11:28:01 Pacific
OS: Windows Vista
Product: Microsoft Excel 2007
Subcategory: General
Tags: excel, formula
Comment:

Using a variation of the table below, i'm trying to figure out a formula that will:

Return the latest date (or largest #) in the "Date" column from all rows where a value from "Value" column is found.
(e.g. if i'm looking for "a", then it should return the latest date (from "Date" where a is found in "Value") = 1/21/2010

Value Date
a 11/15/2009
a 11/16/2009
b 11/17/2009
b 11/18/2009
c 11/19/2009
c 12/20/2010
c 12/21/2010
a 12/22/2010
a 1/01/2010
b 1/02/2010
c 1/20/2010
a 1/21/2010



Sponsored Link
Ads by Google

Response Number 1
Name: Humar
Date: October 27, 2009 at 12:59:43 Pacific
Reply:

Hi,

This can be done with array formulas.

With your data in columns B and C with the first data (a) in B4,
enter a, b and c in cells D4, D5 and D6
In cell E4 enter this formula:
=MAX(IF(B4:B15=$D$4,C4:C15,0))
Note the $ signs,
Now with your cursor inside the formula in the formula bar,
press Ctrl+Shift+Enter at the same time.
If you get this right, the formula will have curly braces around it:
{=MAX(IF(B4:B15=$D$4,C4:C15,0))}

The formula won't drag, so enter these in E5 and E6,
=MAX(IF(B4:B15=$D$5,C4:C15,0))
=MAX(IF(B4:B15=$D$6,C4:C15,0))
after each, use the Ctrl+Shift+Enter triplet to make the formula into an array formula.

This gave me the following:

	B	C		D	E
3	ID	Date		Sort ID	Max
4	a	15-Nov-09	a	22-Dec-10
5	a	16-Nov-09	b	2-Jan-10
6	b	17-Nov-09	c	21-Dec-10
7	b	18-Nov-09		
8	c	19-Nov-09		
9	c	20-Dec-10		
10	c	21-Dec-10		
11	a	22-Dec-10		
12	a	1-Jan-10		
13	b	2-Jan-10		
14	c	20-Jan-10		
15	a	21-Jan-10		

Regards


0

Response Number 2
Name: Bear204
Date: October 27, 2009 at 13:07:22 Pacific
Reply:

Done. Thank you for your help!

BTW, the drag works if i remove the $ for the reference cell :)

Thank you again!


0

Response Number 3
Name: Humar
Date: October 27, 2009 at 13:20:06 Pacific
Reply:

Hi,
Array formulas only become array formulas when you use the Ctrl+Shift+Enter.
If you just hit Enter, the formula doesn't get the curly braces around it and it returns the wrong result.

Entering curly braces from the keyboard doesn't work either - so it has to be the Ctrl+Shift+Enter.

Array formulas run a series of individual formulas on the whole table and internally hold the results from each stage.

In this example the IF(B4:B15=$D$4,C4:C15,0) part of the formula was repeated 12 times
starting with IF(B4=$D$4,C4,0) and
ending with IF(B15=$D$4,C15,0)

Because D4='a', this formula returned zero if the value in column B was not 'a'
If the value was 'a' it returned the date in the same row.

It then ran the MAX function on the 12 individual results.

Regards


0

Response Number 4
Name: Humar
Date: October 27, 2009 at 13:28:13 Pacific
Reply:

Hi,

You said that dragging the formula worked if you removed the $ from the D4 part of the formula.

You should check the other two formulas and see what range of source data they are pointing to.

Click in the formula bar for cell E6 and see the ranges highlighted - they will be two rows out. As your latest dates were all near the end of the table, you still got the right results.

With different data you will get wrong results.

Regards
PS after entering an array formula you may need to use Ctrl+Shift+Enter again. Always check that the Curly braces {} are there.


0

Response Number 5
Name: Bear204
Date: October 27, 2009 at 13:40:01 Pacific
Reply:

Thank you again for your help,

The curly braces setting the array is the lesson learned in this instance :)

I've determined that i can drag the formula and to use it anywhere on the column too. I changed my reference columns to be B:B and C:C to query (as it were) the entire columns.
the result is:
{=MAX(IF(B:B=D4,C:C,0)))}

Gold!

Thanks again!


0

Related Posts

See More



Response Number 6
Name: Humar
Date: October 27, 2009 at 14:10:54 Pacific
Reply:

Hi,

Thanks for the feedback.

Glad it works, and interesting that you can drag the formula if you reference the complete column - I shall remember that !

Regards


0

Sponsored Link
Ads by Google
Reply to Message Icon





Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Excel help: how to reference & return data...

No one can figure out how to..Vista www.computing.net/answers/windows-vista/no-one-can-figure-out-how-tovista/1726.html

How to increase dedicated graphics www.computing.net/answers/windows-vista/how-to-increase-dedicated-graphics-/1297.html

how to remove Novell Client www.computing.net/answers/windows-vista/how-to-remove-novell-client-/2261.html