Can't return multiple values of same input using VLOOKUP/INDEX/MATCH - excel

I've tried searching online to solve this problem but cannot seem to find an appropriate solution to this problem I have.
I am trying to find all of the MAC addresses connected to each Switch in a network.
I am doing this in excel and have the following sample data:
+--------------+------------+--------+
| Mac Address | Switch | Port |
+--------------+------------+--------+
| 00144f601fdf | 6553DC-HA1 | Gi4/42 |
| 00144f601fdf | 6554DC-LA1 | Gi6/1 |
| 00144f601ff2 | 1123DC-MA1 | Gi8/34 |
| 00144f601ff2 | 6554DC-LA1 | Gi6/1 |
| 00144f601ff3 | 1123DC-MA1 | Gi8/35 |
| 00144f601ff3 | 6554DC-LA1 | Gi6/1 |
| 00144f685d38 | 1123DC-MA1 | Gi8/44 |
| 00144f685d38 | 6554DC-LA1 | Gi5/1 |
+--------------+------------+--------+
I have tried using VLOOKUP but obviously that only returns the first value, i've tried playing around with INDEX and MATCH but I haven't got anywhere helpful.
Ideally I'd like to see:
00144f601fdf = 6553DC-HA1
= 6554DC-LA1
00144f601ff2 = 1123DC-MA1
= 6554DC-LA1
And so on... any help on this matter or suggestions for potential solutions would be greatly appreciated!

Your example "I'd like to see" shows all of the switches for each mac address, but your request is for "all of the MAC addresses connected to each Switch."
Assuming your example is what you want to see, then you can insert a column in Excel between the "MAC Address" and "Switch" columns and use a formula in the new column to show MAC addresses only when they change.
If the rows are already sorted by MAC Address, and MAC Address is column A, the formula is
=IF(A2=A1,"",A2)
Just paste that in each cell of the new column and it will how the MAC Address entry only the first time it appears - the result will look like your example above.
fyi if you want a more compressed result, use unique() and transpose() with (optionally) concatenate(). Example at this Google sheet.

If the data is structure like in your example I recommend mike's answer.
If it is unordered you can use the following approach which will always return two results:
In D1: =VLOOKUP(A12,$A$2:$C$9,2,FALSE) (fairly obvious)
In D2:
=VLOOKUP(A12,
OFFSET($A$2,
MATCH(A12,$A$2:$A$9,0),
0,
COUNTA($A$2:$A$9) - MATCH(A12,$A$2:$A$9,0),
2),
2,
FALSE)
This offsets the range to after the first matched MAC address and resizes it to the end of the supplied range (In case you have more stuff below) and runs the VLOOKUP on that.

Related

Determine whether 4th character in cell is numeric or text

I'm trying to find a way to determine if the 4th character in a cell is either a letter or a number. I found a similar thread but their solution isn't working for me.
My example:
| A Column | B Column to return |
| -------- | -------------- |
| BKGB1000 | BKGB |
| BKG41000 | BKG |
=IF(ISNUMBER((LEFT(A1,4))),LEFT(A1,3),LEFT(A1,4))
I have also tried
=IF(ISNUMBER(MID(A1&" ",4,1)),3,4)
The above just isn't working. It keeps returning all 4 characters, so in the 2nd row it returns BKG4 instead of just BKG. Any help would be greatly appreciated!
=IF(ISNUMBER(MID(A2,4,1)*1),"number","letter")
The MID results in text. Multiplying it results in a number provided the character is a number.
Solution. Thanks for the guidence P.b
=IF(ISNUMBER(VALUE(MID(A2&" ",4,1))),LEFT(A2,3),LEFT(A2,4))

Excel - Forumla to seacrh for mutliple terms and show the matching term

I have the challenge that I need to search in Excel for multiple terms and to get the result back for each cell which of the different terms has matched.
I know there is a formula combination to search for multiple terms but this will not give me the matched term back. The exampel below gives only a "0" or "1" back.
=IF(ISNUMBER(SEARCH({"TermA","TermB","TermC"},A1)),"1","0")
| | A | B |
| 1 | This is TermA | TermA |
| 2 | Some TermB Text | TermB |
| 3 | And TermA Text | TermA |
| 4 | another TermC | TermC |
Background I have to do some normalization of the values and look therefore for some forumla which can identify the values and list the match. The values which are used to search for should be later on another page so it can be easily extended.
Thank you for some hints and approaches which will put me into the right direction.
To return all matching terms:
=INDEX(FILTERXML("<t><s>"&SUBSTITUTE(A1," ","</s><s>")&"</s></t>","//s[.='TermA' or .='TermB' or .='TermC']"),COLUMN(A1))
Wrap in an IFERROR() if no match is found at all.
If one has ExcelO365 and you refer to a range, things got a lot easier:
Formula in E1:
=TRANSPOSE(FILTER(C$1:C$3,ISNUMBER(FIND(C$1:C$3,A1))))
=INDEX(FILTER(C:C,C:C<>""),MATCH(1, COUNTIF(A1, "*"&FILTER(C:C,C:C<>"")&"*"), 0))
For use in office 365 version. If previous version replace FILTER(C:C,C:C<>"") with C$1:C$4 for your example or whatever your range of search values may be. Table reference is also possible.
The formula searches for the first match in your list of values if the text including your term contains a matching value anywhere in that text. It returns the first match.

Building dependent picklist by finding associated rows

I have a need for a dependent picklists. The outputted workbook is actually created programmatically which does restrict the way this needs to be built (I'm trying to create everything in Excel first and then finish the programmatic output of the sheet).
I have rows that need dropdowns representing Objects and Fields in a database. So dropdown1 would contain a list of Objects and dropdown2 depends on that to display a list of Fields based on that object.
I have a Ledger sheet containing the data that needs to be represented. Something like this:
| A | B | C |
|--------|--------|---------------|
| People | People | First Name |
| Places | People | Last Name |
| Things | People | Phone Number |
| | People | Email Address |
| | Places | Longitude |
| | Places | Latitude |
| | Things | Color |
| | Things | Shape |
The A column contains all the Objects (People, Places, Things) and is used to populate all the dropdown1's. The B & C columns are used to represent the fields - B being the Object the field belongs to and C being the FieldName. So if I choose People in dropdown1 I want dropdown 2 to contain only values from C that apply to People (First Name, Last Name, Phone Number, Email Address)
I'm struggling to make this work. In another sheet I have succeeded in listing out the values that I would want in dropdown2 using the following formula (where A2 refers to dropdown1) - =IFERROR(INDEX(Ledger!C2:C1000,SMALL(IF(A2=Ledger!B2:B1000, ROW(Ledger!C2:C1000)-1,""), ROW()-1)), "") - but I haven't been able to actually make this work when creating a dropdown (via Data Validation button in excel). How can I get this into a dropdown in excel?

How can I write an Excel formula that will match two columns of data against another table, and only return true if both columns match?

I want to be able to tell if a row in my working table matches another table. Specifically, I only want to know if both values from two columns match.
For example, if james#abc.com has a source of leadgen in both tables, that's a match. Here are some example tables to illustrate that.
My working table
| Email | Source |
|---------------|---------|
| james#abc.com | leadgen | Matched!
| mike#abc.com | leadgen | No Match
| billy#abc.com | leadgen | No Match
| amy#abc.com | leadgen | No Match
Table I want to match against
| Email | Source |
|---------------|---------|
| james#abc.com | leadgen |
| mike#abc.com | popup |
| amy#abc.com | banner |
Here is the formula I tried using.
IF(AND(
MATCH([Email],'secondTable[Email],0),
MATCH([Source],'secondTable[Source],0)),
"Matched!","No Match"
Unfortunately, this returns a match for mike#abc.com because even though his source is popup in the second table, the source value leadgen appears elsewhere. At least that's what I'm interpreting here.
You can simply use COUNTIFS:
=IF(COUNTIFS(secondTable[Source],[Source], secondTable[Email], [Email]),"Matched!","No Match")
=IF(ISNUMERIC(MATCH([Email]&[Source],secondTable[Email]&secondTable[Source],0)),"Matched!","No Match")
Confirm with Ctrl-Shift-Enter instead of Enter when leaving edit mode.

How do I reference cell dynamically in Microsoft Excel

I need to combine string values from (fixed column, variable row) + (fixed column, fixed row) how do I do this?
for example:
| ONE | TWO | THREE
ONE | ONE-ONE | TWO-ONE | THREE-ONE
TWO | ONE-TWO | TWO-TWO | THREE-TWO
THREE | ONE-THREE | TWO-THREE | THREE-THREE*
Any help would be appreciated, thank you!
Assuming top is row one and left is column A for your example, put the following in B2 drag across and down to fill the array.
=CONCATENATE(B$1,"-",$A2)

Resources