How do I look backwards for the most recent match of a text string in a column? - excel-2007

I have an Excel sheet with various data entries that are in date order going down the page, with the dates in column A. I need a formula that will take a text string from an adjacent cell, then look back up a neighbouring column for the most recent match then return the date from column A.
Currently I have this formula in cell H100: =LOOKUP(G100,E100:E$5,A100:A$5).
I want it to look for the text in G100 in column E, going backwards to find the most recent example and then return the corresponding date from column A but despite the LOOKUP command being in reverse it always returns the first example in date order, not the most recent.
I would really appreciate some help from an expert, which I am not!

I am not certain to understand the question, but try
=OFFSET($A$1, 1+MATCH(G100, E$5:E100, 0)0,1,1)
this should catch the first (higher in the sheet) instance of the lookup match.

I would bring it into an Access database where that kind of data manipulation is easy.
But then, I know how to use Access to do those kinds of things and I think it's much harder to do in Excel.

Related

Search entire workbook with two criteria

Gooday, Pls I'm partially new to vba. I have several spreadsheet in a workbook for a work station that is prone to making shortage or surplus in daily delivery as a result of human errors. I want a scenario where I can search the entire workbook to extract data from Column K(which displays shortage or surplus) , but it must meet a certain criteria in Column A(date of delivery) and Column D(location of delivery). In other words, I would like to search Column K to know if there is shortage or surplus for any day I choose to search based on date. Any form of assistance is highly appreciated. Thanks.
Your solution could include an InputBox and the Range.Find Method, where you search column A for date, read in the row, and look at column K of the same row. In fact, the Range.Find example is pretty easily modified for your needs.
But you mention location in Column D, so what constraints are on column D? You'll also need to be more specific about where/how you want to extract the data from column K.

Excel formula not working as expected

I have a sheet that shows max values spent anywhere. So I need to find most expensive place and return it's name. Like this:
Whole sheet.
Function.
Function in text:
=IFS((A6=MAX(D2:D31)),(INDEX(C2:C31,MATCH(A6,D2:D31,0))),(A6=MAX(H2:H31)),(INDEX(G2:G31,MATCH(A6,H2:H31,0))),(A6=MAX(K2:K31)),(INDEX(K2:K31,MATCH(A6,L2:L31,0))))
Basically I need to find a word left to value, matching A6 cell.
Thanks in advance.
Ok.. Overcomplicated!
Firstly, why the three rows? it's a lot easier if you just have one long row with all the data (tell me if you actually need 3 I'll change my solution)
=LOOKUP(MAX(D2:D31);D2:D31;C2:C31)
The MAX formula will lookup the biggest value in the list, the Lookup formula will then match it to the name.
Please note: If more than one object has the maximum price, it will only return the first one. The only way I can think of to bypass that would be to build a macro.
EDIT:
Alright.. Multi Column solution is ugly and requires extra columns that you can just hide.
As you can see you'll need 2 new columns that will find the highest for each row, 2 new columns that will find the value for each of these "highest" (in this case tree and blueberries) and then your visible answer will simply be an if statement finding out which one is bigger and giving the final verdict. This can be expanded with an infinite number of columns but increases complexity.
Here are the formulas:
MAX(H2:H31)
LOOKUP(A5;H2:H31;G2:G31)
MAX(L2:L31)
LOOKUP(C5;L2:L6;K2:K6)
IF(A5>C5;B5;D5)

Copy matching cells based on one column

Please see here for snippet from my spreadsheet, what I am trying to do is fairly simple, however I am unable to find a way to do this after searching through online forums extensively.
Column A contains my order numbers and column B the line items that correspond to each order number.
Column D contains the delivery date as it appears on my printed order sheet, you will see this only pulls through for the first line item on each order - the raw data displays this way and so there is way to change the raw data
Column E simply extrapolates just the date rather than the format Delivery Date: dd/mm/yyyy.
What I would like then, is for column E to have the delivery date copied down to all corresponding cells for each order number - so as per the attached sheet, 30 Jul 2015 would appear for all line items that correspond to order no #1192.
I feel v look up etc will only work to manipulate data once I have these dates copied down. I have tried index match but it doesn't seem to do what I want it to do.
Is there a way to copy down the dates for all line items relative to their order number? I understand that it will probably require copying full lines down column D first and keeping the formula in column E to extrapolate just the date.
Any help is much appreciated
You don't need a macro for this. There are many ways to go about this, I'll show you two, you can figure out the one you like from there.
Select coloumn E, go to Home, Editing, Find & Select, Go To Special. Hit Formulas (if the values are not formulas, go for Constants), and check only Errors. Now type =E2 (or whatever is above your active cell), and hit Ctrl+Enter. It is a wise idea to copy-paste values the whole coloumn E after this.
Another way would be entering this formula in coloumn F (cell F2, then pull it down):
=IFERROR(E2;F1)
Or you could combine this with your original formula, or use a macro to insert the formula in the empty/#error cells etc...
Assuming you are using =RIGHT(D2,LEN(D2)-FIND(":",D2)-1) in E2, then you are well on the way to a solution.
You also mentioned INDEX/MATCH which, if used in column F will pull the Delivery Date in Column E for each Order No:
=INDEX($E$2:$E$31,MATCH(A2,$A$2:$A$31,0))
This finds the position of the first match for your Order No and returns the Delivery Date from column E.

Need a simple search function to display most common value in a column. (with ambiguous choices)

I have a very large array of data with many columns that display different outputs for the values presented. I would like to add a row above the data that will display the most common occurring value or word below.
Generally I would like to have each top of the column (right under the column label in row 1) have the most common value below. I will then use this value for various data analysis functions!
Is this possible, and if so, how? Preferably this will not require VBA, but simply a short code in the cell.
One caveat: The exact values may vary, so there is no set list where I can say "it will be one of these."
Any ideas appreciated!
Try a series of =COUNTIF(A:A,"VALUE TO SEARCH") functions if you want to stay away from VBA.
Otherwise, the best method would be to iterate through each column via VBA. With this method, you can even count the "varying" values and return the count and/or the value itself.
http://www.excel-easy.com/examples/most-frequently-occurring-word.html
This is a single formula you would write at the top of each column. Does not require VBA. You can replace the set range to an entire column, such as (A:A) instead of (A1:A7).
If you mean an array as in a data type, it could work differently but it depends what you're trying to do.
With data from A3 through A16, in A2 enter:
=INDEX($A$3:$A$16,MODE(MATCH($A$3:$A$16,$A$3:$A$16,0)))
This will work for text as well as numbers. Adjust this to match the column size.

Excel - How do I find all relevant rows by typing unique invoice# listed Col A

I have a Worksheet with 10 columns and data range from A1:J55. Col A has the invoice # and rest of the columns have other demographic data. Goal is to type the invoice number on a cell and display all the rows matching the invoice number from col A.
Besides auto filter function, the only thing comes to my mind is VBA. Please advice what is the best way to get the data. Thanks for your help in advance.
Alright, I'm pretty proud of this one. Again avoiding VBA, this one uses the volatile formula OFFSET to keep moving its VLOOKUP search down the table until it's found all matches. Just make sure you paste enough rows of the formula that if there are many matches, there's room for all of them to appear. If you put a border around your match area then it would be clear if you ever ran out of room and needed to copy down the formula some more.
Again, in the main section, it's just a single formula (using index):
=IFERROR(INDEX($A$1:$J$200,$M3,MATCH(N$2,$A$1:$J$1,0)),"")
This gets to be so simple because the hard work of the lookup is done by an initial column which looks up the next row that matches the invoice number. It has the formula:
=IFERROR(MATCH($L$2,OFFSET($A$1:$A$200,M2,0),0)+M2," ")
Here is the working example that goes with those formulas:
Let me know if you need any further description of how it works, but it mostly uses the same rules as above so that it's robust in copying and moving around.
I've uploaded the Excel file so you can play with it, but everything you need to reproduce this feature should be in this solution.
Google Docs - Click link and hit Ctrl+S to download and open in Excel.
A popular solution to this problem is a simple VLookup. Lookup the invoice the user types in on the table A1:J55, and then return an adjascent column's data.
Here's an example of it working:
The formula in the highlighted cell is:
=VLOOKUP($L3,$A:$J,MATCH(N$2,$1:$1,0),FALSE)
What's nice about this formula is you only need to type it once and then you can copy it across and it'll automatically pick out the correct column of the table (that's the match part). The rest is very simple:
The first part says lookup value $L3 (the invoice number typed in),
The second part says look it up in range $A:$J (which is where your table is located). I've shown how you can select the entire columns $A:$J so that you can add and remove data without worrying about adjustin the range in your lookups. (Excel takes care of optimizing the formula so that unused cells aren't checked)
The third part picks the column from which the resulting data will be drawn once a matching row is found.
The FALSE part is an indication that the invoice number must match exactly (no approximate matching allowed)
The $ signs ensure that fixed ranges like the location of your source table ($A:$J) and your lookup value ($L3) don't get automatically changed as you copy the formula across for multiple columns.
The formula is pretty easy to adapt if you want to move around your table and the area where you do your lookup. Here's an example:
Bonus
If you want to add a little spiff, you can add a dropdown to the Invoice # field so that the user gets auto-completion and the option to browse existing values like so: