match formula when first cell in search range is empty? - excel

is it possible to use an empty cell in a match formula?
I have a value in my cell A3. I want to search this value using 'match' in a matrix A4:A13 (or any other matrix). However, in this case, cell A4 is empty (I cannot help it, it is the way figures are returned from another program).
To be able to search in this matrix I thought I could substitute the value in A3 with {empty}.
substituting works. But then, the Match formula does not work.
The actual formula then would be:
=match("";A4:A13;0)
I cannot change the empty cell in my search range. That one is given. Is there something else I can do to make this work?
edit:
this is the objective of my document:
I have a dashboard sheet on which figures presented.
on this sheet, in column A there are first: account name, brand 1, brand 2, brand 3, brand 4, brand 5 (if applicable,), A.VOGEL, OTHER (result of account total minus the sum of all the brands).
So in this case, cells A3:A10. The figures come from a different sheet. This output is like:
a1 = account name (other cells in this row are empty
a2 = empty, b2 contains a value that cannot be used, c2 shows the brand name (and because in this case, it represents the account total and no brand, c2 is empty) and from D2 : L2, there are values, corresponding to the given value in a1.
a3 = empty, b3 contains a value that cannot be used, c3 has the name of the brand and again, in D3: L3 there are the values.
See my example below:
https://www.dropbox.com/s/jv8wvhtw0aa54dd/output%20sheet%201.png
and the dashboard sheet:
https://www.dropbox.com/s/tgt7omkcytm7xef/DASHBOARD%20sheet%201.png
(and after this account 'nl food-drug' many other account will follow with the same structure).
given this structure, I am trying to create a formula which I can easily paste in every row in the dashboard sheet without being concerned my search matrix will be incorrect.
I thought I was able to do this, but I got stuck.
I would like to have only one formula, which contains everything to have the complete search matrix for both the account total and the individual brands, but which also adjusts and refers to the right account. (so adjusts cell references correctly).
I had 2 different formulas which work: 1 for the account total and 1 for the brands. But I am sure there will be a mistake sometime when I copy paste these rows down the sheet.
My formula always refers to the cell where the account name is in. In the example: A3. To always refer to the right cell I was trying the address, match, indirect formula's together.
one formula which is working now:
=ALS(ISFOUT(INDEX(INDIRECT(ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+2;4;1;1;"NIELSEN FD-omzet")&":"&ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+6;12;1;1;);WAAR);VERGELIJKEN($A4;INDIRECT(ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+2;3;1;1;"NIELSEN FD-OMZET")&":"&ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+7;3;1;1;));0);VERGELIJKEN(B$2;'NIELSEN FD-omzet'!$D$2:$L$2;0)));"";INDEX(INDIRECT(ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+2;4;1;1;"NIELSEN FD-omzet")&":"&ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+6;12;1;1;);WAAR);VERGELIJKEN($A4;INDIRECT(ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+2;3;1;1;"NIELSEN FD-OMZET")&":"&ADRES(VERGELIJKEN($A$3;'NIELSEN FD-omzet'!$A:$A;0)+7;3;1;1;));0);VERGELIJKEN(B$2;'NIELSEN FD-omzet'!$D$2:$L$2;0)))
nice formula, right? :-)

=MATCH(TRUE,INDEX(ISBLANK(A4:A13),0),0)

Say B1:B4 is the table of values an A1 is the value to find.
This formula:
=IF(A1="",MATCH(TRUE,INDEX(B1:B4="",0),0),MATCH(A1,B1:B5,0))
will work where A1 is empty or not! For example:
and for empty:
EDIT#1
For the Poster's case this would be:
=IF(A3="",MATCH(TRUE,INDEX(A4:A13="",0),0),MATCH(A3,A4:A13,0))
or just:
=MATCH(TRUE,INDEX(A4:A13=A3,0),0)

Related

Problem extracting data from a cell populated from a formula

I imported a txt document which creates 7 columns of data. One of the data points in the document is a MAC address, however, due to the format of the txt document (and there is no way around this), the MAC address is split up into 6 columns (B-G), with all other pertinent data (non MAC addresses) existing in column B.
I am trying to write a formula to check a cell in column B, and if it contains "BSSID" then it will combine the text in the corresponding row from columns B-G and enters the new value in column H (so it shows as a normal MAC address). If the cell does not contain "BSSID", then the value of that cell just needs to be moved to the corresponding row in column H.
MY PROBLEM IS given the formula below, if the cell contains "BSSID", the corresponding row in column H will only display the value of the cell in the first column, instead of all the columns.
I have tried taking the code, that combines cells in B-G within the formula, and surrounding it in brackets and quotations, with no luck.
I also tried making this a multiple step solution by only running the formula to combine everything in column H, and then in column I, via a formula.
I tried to move the value returned in column H to column I, but I run into the same issue.
And I have tried swapping the return values, just to make sure, I didn't mix up the true return with the false return.
Original Code I would like to get to work:
=IF(ISNUMBER(SEARCH(“BSSID”,A2)),B2&":"&C2&":"&D2&":"&E2&":"&F2&":"&G2,B2)
This is what the code looked like, when I broke it into 2 parts:
Column H: =B2&":"&C2&":"&D2&":"&E2&":"&F2&":"&G2, B2
Column I: =IF(ISNUMBER(SEARCH(“BSSID”,A2)),H2,B2)
Both codes only return the value in cell B2 if true, instead of what should look like a MAC address.
My expected results would be, in a single formula, if B2 contains the string "BSSID" that H2 would show the content of B2-G2 formatted to look like a MAC address; and if B2 does not contain the string "BSSID" then H2 will show the content of B2.
Actual result is that H2, when the formula returns true, only displays B2 and not B2-G2.
I would approach this problem as follows:
Check the cell for BSSID using an IF statement =IF(SEARCH("BSSID",A2), <true>, <false>)
This statement may result in an error though, if "BSSID" isn't found. Your code looks to be fine, but perhaps herein lies the issue. To be sure, we can insert a catch for the errors using IFERROR =IF(IFERROR(SEARCH("BSSID",A2), FALSE), <true>, <false>)
Then, within the <true> section of the IF statement, I would use TEXTJOIN to combine my cells with a colon inbetween ...TEXTJOIN(":",TRUE,B2:G2)...
EDIT: I notice that you say in one location that you are checking cell A2 for "BSSID" and in another you say you are checking cell B2. Perhaps make sure you aren't checking the wrong cell?
=IF(ISNUMBER(SEARCH(“BSSID”,A2)),B2&":"&C2&":"&D2&":"&E2&":"&F2&":"&G2,B2)
...
My expected results would be, in a single formula, if B2 contains the string "BSSID" that H2 would ...

Referencing a named range by formula in data validation

Hello wonderful people.
I have a series of named ranges, A_Colours, B_Colours, etc.
These represent sections of a sorted column in a colour list, sorted by codes for the manufacturer that makes those colours. These are dynamic named ranges, constructed by COUNTA for how many colours have that mfr code. By my calculation, the list should be contiguous, since the column is sorted by code.
I know I can reference the ranges in Data Validation by simply setting =A_Colours as the list source (no quotes). This does work in this case.
However, I have a dropdown to control which A-M range I want to show in the child dropdown.
So, e.g. dropdown in A1 shows A, B, C, D as options.
Dropdown in B1 shows dropdown options relative to the chosen option in A1.
EXAMPLE:
I select A from the list in A1.
In cell B1, I want my dropdown to show all values from named range A_Colours.
I have tried all manner of ways to pass the text string A_Colours to the DV list source field, but all have failed. Either error in formula, or the range evaluates to an error, or it allows me to select only A_Colours from the dropdown.
Example 1:
A1 choose A
B1 DV box:
=INDIRECT("$A$1")&"_Colours"
This gives error "The list source must be a delimited list, or a reference to single row or column."
Could this be because the table list is sorted? I don't think so because the very first example above works.
Example 2: use helper cell in C1 to create text string "A_Colours", by formula:
=$A$1&"_Colours"
Then in DV box for cell B1:
=INDIRECT("$C$1")
Please help me achieve this!
Thank you.
[Edit] SOLUTION:
Create new sheet as directed below.
Create header for each manufacturer ("A" in cell A1).
Enter formula into A2 (as an array formula, Ctrl+Shift+Enter):
=INDEX(Colours, SMALL(IF((INDEX(Colours, , 1)=INDEX(MFR,MATCH(A$1,MFR[MFRName],0),2)), MATCH(ROW(Colours), ROW(Colours)), ""), ROWS($B$1:B1)), COLUMNS($A$1:$B1))
I adapted it a bit, but credit for this goes to https://www.get-digital-help.com/2009/09/28/extract-all-rows-from-a-range-that-meet-criteria-in-one-column-in-excel/
Apply the formula down to the last plus a few to allow for expansion.
Apply the formula across to your last header.
Now you have lists which are definitely contiguous and single-column and not dynamic, so meet the stringent criteria for data validation.
Create a named range for each list, using the exact name keeps it simple but I chose to add "Name" to the end, e.g. Mfr1Colours.
Reference them in the DV source list field (for cell B2 in our original sheet) like:
=INDIRECT($B$2&"Colours")
What this does:
Looks in the Colours table:
MFR Code Colour Code
Finds the first matching instance of the MFR Code in cell A1 of our original sheet ("A") from the Manufacturer table "MFR", which has columns:
MFRName Code
Pulls out the row by the MATCH(ROW(Colours,Row(Colours),"").
Checks which row and column you want by the ROWS and COLUMNS at the end.
If you have a spare, helper range, where you would make a simple codetable with 2 columns - Color_Reference, Color_Names and name it c_colors:
A A_Colour
B B_Colour
C C_Colour
You could use this in CV list configuration for dropdoon on cell B1:
=INDIRECT(VLOOKUP(A1;c_colors;2;FALSE))
Try to look at the examples here, it may help you as well: http://www.contextures.com/xlDataVal02.html

Ignore Duplicates and Create New List of Unique Values in Excel with offset

My question is related to a question asked earlier, but as I am a new member I was not able to comment on that question.
The earlier question asked how we can dedupe a list in a workbook to create a new list of unique values on another sheet in the same workbook. The top voted solution given by #achaudhr works for me but in that I need to specify the exact cells the formula needs to reference. In the comments on that answer #Dan has mentioned that we must use OFFSET if we are referring to a dynamic range.
This is the formula I am using at the moment:
B2=INDEX($A$2:$A$20, MATCH(0, COUNTIF($B$1:B1, $A$2:$A$20), 0))
I have tried using offset with this formula but I guess I am doing something wrong because it keeps giving me #N/A as a result.
If my data was in column A (as per the above formula), I want to be able to change the ":$A$20" part of the range dynamically. The list in column A changes as per an input I put in the workbook on another sheet (let's call it Sheet 3). Hence I cannot hardcode the cells in the index formula range or else I have to change this range every time my list updates.
Based on the above layout, the cell in E2 calculates the max cell number for the list in column A on sheet 1. This number changes when the input in Sheet 3 changes.
I edited the above formula to use OFFSET to reference E2 in the following way:
B2=INDEX(OFFSET('Sheet 1'!$A$1,'Sheet 1'!$E$2,0), MATCH(0, COUNTIF($B$1:B1, OFFSET('Sheet 1'!$A$1,'Sheet 1'!$E$2,0)), 0))
This formula is returning #N/A (and I did press Ctrl + Shift + Enter so its not because of that).
I hope the group here can help me solve this. Look forward to the inputs and thanks for all your help.
Thanks,
Neha
The way to use OFFSET in a dynamic range determining formula, where it is column length that varies, is to use that value as the [height] parameter.
So, in the case of your example, the formula would look like:
B2: =IFERROR(INDEX(OFFSET($A$1,1,0,$E$2-1), MATCH(0, COUNTIF($B$1:B1, OFFSET($A$1,1,0,$E$2-1)), 0)),"")
Reference: $A$1 (could also set this at $A$2 with a 0 Row offset
Row Offset: 1 (since A1 contains the header)
Column Offset: 0
[height]: Contents of $E$2 minus 1 (since we are not including the header in the list)
[width]: left blank

Excel: Unique codes referencing properties of each product on an invoice

I have been generating invoices by manually inputing the information for each product.
What I would like to do is type in a unique product code (E.g., "01-A") and in the same row automatically return the color, size, price, etc. ("properties") of the product.
I have a separate "database" sheet with these data and the product code in the same column.
I have attached a graphical example illustrating this idea.
Thank you very much for your assistance!
You need a lookup - in this case a VLOOKUP.
=VLOOKUP(Value you want to look up, range where you want to lookup the value, the column number in the range containing the return value, Exact Match or Approximate Match – indicated as 0/FALSE or 1/TRUE).
For example:
=VLOOKUP(B5, Sheet2!$C$2:$G$50, 2, FALSE)
Where B5 is the product code you enter, Sheet2!$C$2:$G$50 is the table with the product details on the other sheet, 2 means the second column (i.e. size), and FALSE to say only lookup if there is a match.
See the Microsoft reference.
Assuming your Sheet1 is as follows
Then, in Cell B5 of Sheet2 enter the following formula
=IFERROR(VLOOKUP($A5, Sheet1!$A$5:$D$7, COLUMN(B$1)-COLUMN($A$1)+1, FALSE),"")
Drag/Copy this formula down and across (to right) as required. See image for reference.

Is there a 2 Value Look up function in MS Excel that can perform the following?

I am going crazy over this. It seems so simple yet I can't figure this out. I have two worksheets. First worksheet is my data. Second is like an answer key. Upon checking checking, A1:B1 in Sheet 1 is a match with the conditions in Row 52 in SHEET 2, therefore, the value in Column C is "MGC". What is the formula that will perform this function? It's really hard to explain without the data so I pasted a link of the sample spreadsheet. Thank you so much in advance.
sample spreadsheet here. https://docs.google.com/spreadsheets/d/1_AjuNfCdGfEM-XkqPa6W4hSIxQg4NM2Vg4c2C1pQ_vQ/edit?usp=sharing
screenshot here. (wont let me post i have no reputation)
In Sheet2, insert a column in front of Column A and put the formula in A2 =C2&D2.
Then in Sheet1, Cell C2 the formula =vlookup(A2&B2,Sheet2!A:B,2,0).
the first make a concatenated key to lookup, then the second looks up that key.
How about a index(match())? If I've understood correctly you need to match across both the A and B column in sheet one, checking for the relevant values in B and C on sheet 2 to retrun worksheet 2 column a to worksheet 1 column c.
third version try:
=INDEX(Sheet2!$C$1:$C$360,MATCH(Sheet1!A1&Sheet1!B1,Sheet2!$B$1:$B$360&Sheet2!$C$1:$C$360,0))
Basically what this does is use concatenation, the & operator, to specify you are looking for "Criteria A" & "Criteria B" in sheet 1, which makes the string "Criteria A Criteria B", which is supplied in the first part of the match function.
In the second it then says match this against all of my variables in sheet 2 in the same way with concantenation.
The final part of match function (0) specifies you want an 'exact' match
It then supplied this as a reference to the index function, which then finds the row intersecting with the value you want, and returns that.
As noted here https://support.microsoft.com/en-us/kb/59482 this is an array formula, so it behaves differently, and must be input differently. https://support.office.com/en-za/article/Guidelines-and-examples-of-array-formulas-7d94a64e-3ff3-4686-9372-ecfd5caa57c7
There are (at least) 2 ways you could do this without VBA.
USING A SORTED LIST
The first relies on the assumption that your data can be re-sorted, so that everything "Unreported" is in the top, and everything "reported" is together below that (or vice versa). Assuming that this is the case (and it appears to already be sorted like this),we will use the function OFFSET to create a new range which shows only the values that align with either being "Unreported" or "Reported".
Offset takes a given reference to a point on a sheet, and then moves down/up & left/right to see what reference you want to return. Then, it returns a range of cells of a given height, and a given width. Here, we will want to start on Sheet2 at the top left, moving down until we find the term "Unreported" or "Reported". Once that term is found, we will want to move one column to the right (to pull column B from sheet 2), and then have a 'height' of as many rows as there are "unreported" or "reported" cells. This will look as follows in A1 on sheet 1, copied down:
=OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),1)
This says: First, start at cell A1 on sheet2. Then find the term in A1 (either "unreported" or "reported", on sheet2!A:A (we subtract 1 because OFFSET starts at A1 - so if your data starts at A1 we need to actually stay at "0". If you have headers on sheet2, you will not need this -1). Then, move 1 column to the right. Go down the rows for as many times as Sheet2 column A has the term found in Sheet1 A1. Stay 1 column wide. Together, this will leave you with a single range on sheet2, showing column B for the entire length that column A matches your term in sheet1 A1.
Now we need to take that OFFSET, and use it to find out when the term in Sheet1 B1 is matched in Sheet2 column B. This will work as follows:
=MATCH(B1,[FORMULA ABOVE],0)
This shows the number of rows down, starting at the special OFFSET array created above, that the term from B1 is matched in column B from sheet2. To use this information to pull the result from column C on sheet 2, we can use the INDEX function, like so:
=INDEX([FORMULA ABOVE],MATCH(B1,[FORMULA ABOVE],0))
Because this would be fairly convoluted to have in a single cell, we can simplify this by using VLOOKUP, which will only require the OFFSET function to be entered a single time. This will work as follows:
=VLOOKUP(B1,[FORMULA ABOVE],2,0)
This takes the OFFSET formula above, finds the matching term in B1, and moves to the 2nd column to get the value from column C in sheet2. Because we are going to use VLOOKUP, the offset formula above will need to be adjusted to provide 2 columns of data instead of 1. Together, this will look as follows:
FINAL FORMULA FOR SHEET1, C1 & COPIED DOWN
=VLOOKUP(B1,OFFSET(Sheet2!$A$1,MATCH(A1,Sheet2!A:A,0)-1,1,COUNTIF(Sheet2!A:A,A1),2),2,0)
OPTION USING ARRAY FORMULAS
The above method will only work if your data is sorted so that the REPORTED and UNREPORTED rows are grouped together. If they cannot be sorted, you can use an ARRAY FORMULA, which essentially takes a formula which would normal apply to a single cell, and runs it over an entire range of cells. It returns an array of results, which must be reduced down to a single value. A basic array formula looks like this [assume for this example that A1 = 1, A2 = 2...A5 = 5]:
=IF(A1:A5>3,A1:A5,"")
Confirm this (and all array functions) by pressing CTRL + SHIFT + ENTER, instead of just ENTER. This looks at each cell from A1:A5, and if the value is bigger than 3, it gives the number from that cell - otherwise, it returns "". In this case, the result would be the array {"";"";"";4;5}. To get the single total of 9, wrap that in a SUM function:
=SUM(IF(A1:A5>3,A1:A5,""))
In your case, we will want to use an array formula to see what row in Sheet2 matches A1 from Sheet1, and B1 from Sheet1. This will look like this:
=IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW($B$1:$B$100),""),"")
This checks which rows in column A from sheet 2 match A1. For those that do, it then checks which rows in column B from sheet 2 match B1. For those, it pulls the row number from that match. Everything else returns "". Assuming no duplicates, there should only 1 row number which gets returned. To pull that number from the array of results, wrap the whole thing in a MATCH function. Now that you have the row number, you can use an INDEX function to pull the result in Column C with that row, like this:
FINAL ARRAY FORMULA METHOD
=INDEX($C$1:$C$100,MAX(IF(Sheet2!$A$1:A$100=A1,IF(Sheet2!$B$1:$B$100,ROW(Sheet2!$B$1:$B$100),""),"")))
Remember to confirm with CTRL + SHIFT + ENTER instead of just ENTER, when you type this formula. Note that I didn't refer to all of Sheet2!A:A, because array formulas run very slowly over large ranges.
The following formula should work without making any changes to the datasheets.
=INDEX(Sheet2!$A$1:$A$360,MATCH(Sheet1!A1,IF(Sheet2!$C$1:$C$360=Sheet1!B1,Sheet2!$B$1:$B$360),0))
Remember to save this formula as an array with CTRL+SHIFT+ENTER
Documentation on how to use INDEX and MATCH against multiple criteria can be found on Microsoft Support.
It's not clear what you want to do with the multiples that do not have corresponding matches. txed is listed as Unreported twice in Sheet1; kntyctap is listed as Unreported three times. There are only one corresponding match on Sheet2 for each of these.
Non-array Standard Formulas for multiple criteria matches
For Excel 2010 and above use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999,AGGREGATE(15,6,ROW(1:999)/((Sheet2!$B$1:$B$999=A2)*(Sheet2!$C$1:$C$999=B1)), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
For version of Excel prior to 2010 use this standard formula in Sheet1!C1:
=IFERROR(INDEX(Sheet2!$A$1:$A$999, SMALL(INDEX(ROW($1:$999)+((Sheet2!$B$1:$B$999<>A1)+(Sheet2!$C$1:$C$999<>B1))*1E+99, , ), COUNTIFS(A$1:A1, A1, B$1:B1, B1))), "")
I've handled error with the IFERROR function in that latter formula. Excel 2003 and previous may have to use an IF(ISERROR(..., ...)) combination.

Resources