Need Formula To Find Data

M

Monte Sliger

I am using Excel 2000.

I need a formula to find particular data within an array of data. I have a
worksheet displaying inventory activity. Cell A1 is a cutoff date. Cells
A4 thru A1000 are the dates of the activity. Cells B4 thru B1000 are
descriptions. Cells C4 thru C1000 are additions. Cells D4 thru D1000 are
subtractions. Each row will have a date, description and either an addition
or subtraction amount (but not both on the same row).

I need a formula to return the date, description and adddition amount of the
last row with an amount in the additions field where the date is on or
before the cutoff date.

Any help you can give me will be greatly appreciated.


Thanks,
Monte Sliger
 
D

Don Guillett

You can use the MATCH function to find the row in col A and then incorporate
that as the row in the INDEX function to include all columns.
 
C

Clivey_UK

You could try this formula
=VLOOKUP(A1,A4:D1000,2) in B1. This first looks up the date in cell A
- say the answer is 21 March. It then finds the latest 21 March (or 2
March if there is no 21 March) in the table below and shows what is i
column 2 (Description) for that date. Use ,3 for looking up additions
and ,4 for subtractions.
Cliv
 
M

Monte Sliger

Clive,

Unfortunately, that doesn't work because it returns data from the last row
before the cutoff date regardless of whether there is a value in the
addtions field or not. I need the data from the last row which is both
before the cutoff date and has an amount in the additions column. This row
may be the last row in the worksheet or any row above it.

Lets suppose I have three rows in the worksheet (all befre the cutoff date)
with row 1 being a row with a number in the additions field and rows 2 and 3
having numbers in the subtractions field. I need to return the data from
row 1 not rows 2 or 3.


Thank you for trying to help me.
Monte Sliger
 
M

Monte Sliger

Don,

I think this may be the answer but in looking at those formulas I am
confused as to how to incorporate this into one formula. Could you provide
a simple example or point me to where I could find one?


Thanks for your help.
Monte Sliger
 
D

Don Guillett

try re-reading my post where you look in the help index for the MATCH
function to find the row and then the index function using the match formula
in place of the row. Have you looked in the HELP index?
 
M

Monte Sliger

Don,

Yes I did look in the help index. I can return the value of the last row
where the date is less than or equal to the cutoff date (MATCH(A1,A4:A100,1)
and I can return the value of the last row where the additions amount is
less than or equal to a number (MATCH(100,C4:C100,1) but I cannot figure out
how to put these two formulas together. I tried
(MATCH(A1,A4:A100,1)*MATCH(100,C4:C100,1)) but this does not return the
correct value.

Sorry if I sound dumb, but I cannot figure out how to put two match formulas
together to return the value of a unique row where the date is less than or
equal to A1 and the additions amount is GREATER than 0. Match always
returns the largest value that is less than or equal to lookup value or the
smallest value greater than or equal to lookup value depending on the match
type you select. I need the largest value (row) that is greater than 0 or
else the largest value (row) that is not blank if that is an easier way to
look at it.


Again I appreciate all your help.
Monte Sliger
 
D

Don Guillett

From the help index for INDEX. Here is where you use the match formula for
the ROW part of the index formula.
INDEX
See Also

Returns the reference of the cell at the intersection of a particular row
and column. If the reference is made up of nonadjacent selections, you can
pick the selection to look in.

The INDEX function has two syntax forms: array and reference. The array form
always returns a value or an array of values; the reference form always
returns a reference.

Syntax 2

Reference form

INDEX(reference,row_num,column_num,area_num)

Reference is a reference to one or more cell ranges.

a.. If you are entering a nonadjacent range for the reference, enclose
reference in parentheses.

b.. If each area in reference contains only one row or column, the row_num
or column_num argument, respectively, is optional. For example, for a single
row reference, use INDEX(reference,,column_num).

Row_num is the number of the row in reference from which to return a
reference.

Column_num is the number of the column in reference from which to return a
reference.

Area_num selects a range in reference from which to return the
intersection of row_num and column_num. The first area selected or entered
is numbered 1, the second is 2, and so on. If area_num is omitted, INDEX
uses area 1.

a.. For example, if reference describes the cells (A1:B4,D1:E4,G1:H4),
then area_num 1 is the range A1:B4, area_num 2 is the range D1:E4, and
area_num 3 is the range G1:H4.

Remarks

a.. After reference and area_num have selected a particular range, row_num
and column_num select a particular cell: row_num 1 is the first row in the
range, column_num 1 is the first column, and so on. The reference returned
by INDEX is the intersection of row_num and column_num.
b.. If you set row_num or column_num to 0 (zero), INDEX returns the
reference for the entire column or row, respectively.

c.. Row_num, column_num, and area_num must point to a cell within
reference; otherwise, INDEX returns the #REF! error value. If row_num and
column_num are omitted, INDEX returns the area in reference specified by
area_num.
d.. The result of the INDEX function is a reference and is interpreted as
such by other formulas. Depending on the formula, the return value of INDEX
may be used as a reference or as a value. For example, the formula
CELL("width",INDEX(A1:B2,1,2)) is equivalent to CELL("width",B1). The CELL
function uses the return value of INDEX as a cell reference. On the other
hand, a formula such as 2*INDEX(A1:B2,1,2) translates the return value of
INDEX into the number in cell B1.
Example

The example may be easier to understand if you copy it to a blank worksheet.

How?

1.. Create a blank workbook or worksheet.
2.. Select the example in the Help topic. Do not select the row or column
headers.


Selecting an example from Help

3.. Press CTRL+C.
4.. In the worksheet, select cell A1, and press CTRL+V.
5.. To switch between viewing the results and viewing the formulas that
return the results, press CTRL+` (grave accent), or on the Tools menu, point
to Formula Auditing, and then click Formula Auditing Mode.


1
2
3
4
5
6
7
8
9
10
11
A B C
Fruit Price Count
Apples 0.69 40
Bananas 0.34 38
Lemons 0.55 15
Oranges 0.25 25
Pears 0.59 40

Almonds 2.80 10
Cashews 3.55 16
Peanuts 1.25 20
Walnuts 1.75 12
Formula Description (Result)
=INDEX(A2:C6,2,3) The intersection of the second row and third
column in the range A2:C6, which is the content of cell C3. (38)
=INDEX((A1:C6,A8:C11),2,2,2) The intersection of the second row
and second column in the second area of A8:C11, which is the content of cell
B9. (3.55)
=SUM(INDEX(A1:C11,0,3,1)) The sum of the third column in the
first area of the range A1:C11, which is the sum of C1:C6. (216)
=SUM(B2:INDEX(A2:C6,5,2)) The sum of the range starting at B2,
and ending at the intersection of the fifth row and the second column of the
range A2:A6, which is the sum of B2:B6. (2.42)
 
H

Herbert Seidenberg

Assuming your data looks like this:
cutoff
2/2/2006

date desc add sub
1/28/2006 A 1
1/29/2006 B 2
1/30/2006 C 2
1/31/2006 D 8
2/1/2006 E 3
2/3/2006 F 5
2/4/2006 G 1
2/5/2006 H 3
2/6/2006 I 6
2/7/2006 J 9

1/31/2006 D 8

Name the data with the headers
(cutoff, date, desc, add, sub) as suggested above.
Example: Select the 44 cells from <date> to <9> and
Insert > Name > Create > Top Row
Also define this name
Insert > Name > Define
Names in Workbook > rown
Refers To > =ROW(INDEX($A:$A,1):INDEX($A:$A,ROWS(date)))
The 3 output formulas for date, desc and add are respectively
=INDEX(date,MAX((date<=cutoff)*(add>0)*rown))
=INDEX(desc,MAX((date<=cutoff)*(add>0)*rown))
=INDEX(add,MAX((date<=cutoff)*(add>0)*rown))
Enter these 3 formulas with Cntrl+Shift+Enter instead of just Enter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top