Problem extracting data from a cell populated from a formula - excel

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 ...

Related

How can I keep the same cell reference in if function, until the if function is true/false?

I have the following function in excel:
INDIRECT(CHAR(COLUMN()+53)&O1+1)
This function has to be the outcome of an if-statement when the statement is true. I don't want the O1 to change to O2, O3, etc.. when I drag the function down, until the statement is true. From there I want the function to change this cell reference in ascending order. So as long as the if statement is false, the reference needs to be O1.
I know that absolute referencing can be used to keep the same cell-reference ($O$1), but then the cell reference doesn't change when the statement is true either.
My data looks like this: enter image description here
My complete formula looks like this: enter image description here
=IF(P2=INDIRECT(CHAR(COLUMN()+51)&O1+1);IF(INDIRECT(CHAR(COLUMN()+51)&O2+1)="";INDIRECT(CHAR(COLUMN()+53)&O1+1);INDIRECT(CHAR(COLUMN()+51)&O2+1));IF(INDIRECT(CHAR(COLUMN()+53)&O2+1)="";"";INDIRECT(CHAR(COLUMN()+51)&O2+1)))
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
I hope that this description gives a clear view of what I want to do.
Thanks in advance.
What I want to do is to fill a column with values of the first column in the data until the cells are empty. Then I want to fill the column with data from the i+2th column (so from column C I go to column E). In order for this to happen, I want the first cell of (column E in this case) to stay the same, until column C is empty and the column starts taking values from column E.
It's not the same kind of solution, but this might suit your needs better than your original formula:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
If you need it for more than 2 columns, just extend the formula by following this pattern:
=
IFERROR(INDEX(OFFSET($A$1,2,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,2,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($A1)+2-COUNTA(A:A)-COUNTA(B:B)),
IFERROR(INDEX(OFFSET($D$1,2,0,COUNTA(D:D)-1,1),ROW($A1)+3-COUNTA(A:A)-COUNTA(B:B)-COUNTA(C:C)),
""))))
Sample implementation: https://i.stack.imgur.com/MAtxW.png
I've made considerations for your extra blank row between the header and the first row of data. For anyone wanting to use this formula without the blank row in their data set simply change the Offset-Row parameter from 2 to 1:
=
IFERROR(INDEX(OFFSET($A$1,1,0,COUNTA(A:A)-1,1),ROW($A1)+0),
IFERROR(INDEX(OFFSET($B$1,1,0,COUNTA(B:B)-1,1),ROW($A1)+1-COUNTA(A:A)),
""))
You can stick the formula anywhere in your worksheet, but don't forget to change the column letters to suit the location of your fields. In your case, probably:
=
IFERROR(INDEX(OFFSET($C$1,2,0,COUNTA(C:C)-1,1),ROW($C1)+0),
IFERROR(INDEX(OFFSET($E$1,2,0,COUNTA(E:E)-1,1),ROW($C1)+1-COUNTA(C:C)),
""))
Be aware that you need to make sure your columns don't contain rows with blank cells in between names, as this will cause it to skip an equal number of names at the bottom of the column.
EDIT:
I just realized your system uses semi-colons ";" to parse Excel formulas (mine uses commas ","). Please take note of that when copying these formulas to your spreadsheets. Here's the formula again but using ";"...
=
IFERROR(INDEX(OFFSET($C$1;2;0;COUNTA(C:C)-1;1);ROW($C1)+0);
IFERROR(INDEX(OFFSET($E$1;2;0;COUNTA(E:E)-1;1);ROW($C1)+1-COUNTA(C:C));
""))

Vlookup with wildcard not working (partial string match) on long values

I understand the basic use of the vlookup with wildcard but I'm running into a problem lately.
I need to lookup a value that contained in a cell as a part of string. In the below Sample I look up colA in the colC, with should be found, then return the values in col D into col B.
I use =VLOOKUP("*"&A1&"*",C$1:D$2,2,0), and it only works for B1.
Why do B2 & B3 don't work out the same way? Any solution?
Sample:
As per your investigation and comment by Axel, VLOOKUP doesn't work with values over 255 characters in length. A workaround is use an array formula with the SEARCH function which handles much longer values. Double click into cell B1 and paste this formula, then save it by pressing CTRL + SHIFT + ENTER instead of just pressing Enter by itself:
=INDEX($D$1:$D$2,MATCH(TRUE,ISNUMBER(SEARCH(A1&",",$C$1:$C$2&",")),0))
If you enter it correctly, selecting the cell will show {curly braces} around the formula and it should evaluate to your desired result.
This formula first creates an array searching for the position of A1 in every cell in C1:C2. The array will consist of numbers (when A1 is found) and errors (when A1 is not found).
ISNUMBER then creates an array of TRUE (when A1 is found) and FALSE (when A1 is not found)
MATCH then finds the first TRUE value in the array.
INDEX then returns the corresponding value from the D1:D2.
Edit: The formula now searched for the value in A1 followed by a comma. This ensures that an exact match is made. To also ensure that the formula can match against the last value in any cell in column C, a comma is also added to the end of the values in column C.

Excel Formula with if, then

I need to write a formula in Excel that performs the following:
If cell A1 contains the text ".png",".jpeg" then cell B1 = Image
If cell A2 contains the text ".mov",".mp4" then cell B2 = Video
And so on...
Also, is it possible to apply this validation with additional validation already applied? Like a list.
Solution
I broke the solution to parts so you won't be shocked by a long line of formula.
What I need to get it to work
Extract the suffix of a string, I've done that using the length of the string in column B and then putting it in column C.
B2=LEN(A2)
C2=IFERROR(RIGHT(A2,LEN(A2)-SEARCH(".",A2)),$J$4)
The IFERROR is in case the file doesn't contain a dot and then column C will show the message in cell $J$4.
Get the type by a so called "database" table which I've built to map which suffix belongs to which type of file
D2=IFERROR(INDEX($F$2:$G$8,MATCH(C2,$F$2:$F$8,0),2),$J$6)
I've used the INDEX and MATCH functions to fetch the data from the database.
The IFERROR in this case means - I didn't find the desired prefix in the Database table (in $F$2:$G$8)
After filling these formulas, drag down the data to the rest of the cells and you'll get the desired results.
Here's an image of my Excel file and below it you'll see the cells mapping to prevent you from guessing where is what.
Cells Mapping
Database = $F$2:$G$8
No Dot string = $J$4
Not a valid suffix string = $J$6
=IF(
OR(ISNUMBER(SEARCH(A1,".png")),ISNUMBER(SEARCH(A1,".jpeg")))
,"Image"
,IF(
OR(ISNUMBER(SEARCH(A2,".mov")),ISNUMBER(SEARCH(A2,".mp4")))
,"Video"
,"")
)
Please check for the closing brackets yourself as I just typed this off my head.
That formular should be used for cell B1

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.

How can I return a value for a cell containing data from a number of cells?

Using Excel/Numbers, I am wanting to use a formula which checks if a cell contains any of the data contained in a number of other cells, if if it does I want to return a custom value or write out another formula, if it does, I want it to retune "n/a"
Column A (The options)
DNS
Hosting
Mapping
No Appointment
Reference
Column B (The column containing the formula)
Column C (The criteria to search for)
DNS
Hosting
Mapping
No Appointment
Reference
Whilst the syntax is wrong, I'm looking to achieve this:
If A2 contains any of the data from column B then return "Cakes" if not return "N/A"
If A3 contains any of the data from column B then return "Cakes" if not return "N/A"
etc. etc.
I've tried using
=IF(LOOKUP(C2,E$2:E$5,TRUE)=TRUE,"CAKES","N/A")
The correct output was obtained on the first cell alone but the formula output errors for all other cells.
Using the following formula, I have achieved what I was wanting to do, but I welcome additional formula or any tidier ways of achieving the same goal
=IF(COUNTIF(A$2:A$50,B$2:B$5)=1,"CAKES","N/A")

Resources