Spreadsheet : every possible combination of 2 columns into one single colum - excel

and sorry if this question looks familiar, I saw a lot of similar problems but couldn't understand the trick, and I completely stuck.
I have a spreadsheet with 2 columns :
A with Countries
B with their code
A B
Belgium BE
England EN
France FR
Luxembourg LX
Netherlands NL
Spain SP
I'm trying to generate generate a matrix representing all the possible travels : Travel from A to A, from A to B, from B to A, and from B to B. The only restriction is not to travel from a country to itself.
At the end I want to generate the result in a single column C, like this :
Travel from Belgium to England Travel from Belgium to France
Travel from Belgium to Luxembourg Travel from Belgium to
Netherlands Travel from Belgium to Italy Travel from Belgium
to Spain Travel from England to Belgium Travel from England to
France Travel from England to Luxembourg Travel from England
to Netherlands Travel from England to Italy Travel from
England to Spain etc Travel from Belgium to EN Travel from
Belgium to FR Travel from Belgium to LX Travel from Belgium to
NL etc Travel from BE to EN Travel from BE to FR
Travel from BE to LX etc Travel from BE to England Travel
from BE to France etc
Can anyone help me with that ? I tried several tricks with concatenation and JOIN, but I don't get anywhere ...
Thanks a lot in advance

You can run through each value in column A and associate it with a staggered value from column B but you will have to perform some mathematical trickery using the INT function and MOD function to have the sixth entry in column A associated with the first entry in column B.
        
The formulas in C2:E2 are,
=INDEX(A$2:A$7, INT((ROW(1:1)-1)/(COUNTA(A$2:A$7)-1))+1)
=INDEX(B$2:B$7, MOD(MOD((ROW(1:1)-1), (COUNTA(B$2:B$7)-1))+INT((ROW(1:1)-1)/(COUNTA(B$2:B$7)-1))+1, COUNTA(A$2:A$7))+1)
="Travel from "&C2&" to "&D2
There may be a more elegant way of looping through the destinations while skipping the origin but this works and it is not calculation intensive despite the apparent complexity of the formula(s).
I've used the COUNTA function to determine the number of entries rather than hard-code in ordinal numbers. You should be able to transcribe this for more or less entries by following and modifying the referenced cell ranges.

Related

vba concatenate three (dynamic) tables into a master one

I am wanting to concatenate separate tables from separate excel worksheets to create one master one.The issue with the tables is that they are dynamic ie, one table could have 100 rows, the other one could have 240, third table could have 50 for example. The tables themselves were generated by quite a few different processes, essentially they had individual filters applied and then were copied and pasted into these separate excel worksheets… ready to be used to concatenated!
I’ve managed to do all of the processes in vba so could prefer to stick with it. I don’t want to use power query (Because of connection issues and also wanted this to be automated). I also don’t want to get involved with pivot tables or do this in the sql database. This is for quite a few different reasons… and so would prefer to stick to VBA.
Ie
Table 1
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
Table 2
Column a column b column c
China 300 4
Australia 0.1 4
America 100 4
Table3
Column a column b column c
Bali 100 4
England 0.1 5
NZ 200 8
Result
Column a column b column c
Africa 100 4
Australia 0.1 5
America 200 7
China 300 4
Australia 0.1 4
America 100 4
Bali 100 4
England 0.1 5
NZ 200 8
If anyone has any recommendations, would love to hear

Excel formula for aggregation and filtering

Is it possible to aggregate values on one excel tab and display on another tab?
In addition to that can we also filter on one of the columns as we aggregate?
For example, Sheet1 has 3 columns - (Continent, City, Ignore)
Continent City Ignore
Europe Paris N
Europe London N
Europe Liverpool N
Europe Rome N
Europe Oslo Y
Asia Tokyo N
Asia Osaka N
Asia Dubai N
Asia Bangkok Y
Asia Mumbai N
Africa Cairo Y
I want my Sheet2 to display the number of cities per continent taking into account the "Ignore" flag.
Continent #Cities
Europe 4
Asia 4
Africa 0
Since 3 Cities are marked as Ignore=Y, we don't want to count them.
It came as one of the recommended pivot tables, but I'm trying to build this using excel formulas so I can build on that if needed.
Prefer excel formulas over VBA or Macro.
Using your sample data...
Formula in F2:
=COUNTIFS($A$2:$A$12,E2,$C$2:$C$12,"N")
Drag down...

Excel: search two columns against another two columns to return a value fron a third

Got a bit of a pain. So got an interesting issue, basically. Have a long list of entities (200 plus) and I need to match them against a code which I have in another list. So from the entity list, I have the name and country of the entity (Name in column A, country in column D), I need to populate Column F with the code from the other list, or add unknown if a code cant be found.
So, tried to build the query by using the & operator
So =MATCH(A2&D2 to use as key, giving me a value like 'cool companyUNITED KINGDOM'.
In the second list (imported to sheet 2) contains the following columns
Code Name Country
So I want to search an array where Name and country have been combined:
=MATCH(A2&D2,Sheet2!B2:B99999&Sheet2!C2:C99999,0)
I then try to get the index back, so my complete list looks like
=INDEX(Sheet2!A2:C99999, MATCH(Sheet2!A2&Sheet2!D2,Sheet2!B2:B99999&Sheet2!C2:C99999,0))
And all I get back is #Value
Any suggestions
Edit: More infor
So sheet one looks like this (Its column C I need to populate from the code in column A, sheet two)
Entity name Status GIIN Country
Ben Dist Ltd NFFE N/a UNITED KINGDOM
Karamara Sdn Bhd PFFE N/a MALAYSIA
Farbion Trade (Curacao) N.V. LFFI N/a
Tentorim (International) B.V. LFFI N/a NETHERLANDS
Catamo B.V. TLTD N/a NETHERLANDS
Ben Dist Deutschland GmbH FLTD N/a GERMANY
Ben Dist Investments B.V. PFFE N/a NETHERLANDS
Ben Dist Limited TLTD N/a UNITED KINGDOM
Complete Solution Service Limited GLRS N/a UNITED KINGDOM
BDLT S.A. de C.V. TLTD N/a MEXICO
Telsa Telco Services SLTD N/a CHILE
And the second list will look like this
GIIN FINm CountryNm
AAAUG3.99999.SL.764 Asset Plus HSI Fund THAILAND
AABEIL.99999.SL.528 Gresham Capital CLO II B.V. NETHERLANDS
AAB36F.99999.SL.470 Maitland Malta Limited MALTA
AACRQK.99999.SL.756 BBGI GROUP SA SWITZERLAND
AADAD7.99999.SL.528 E-MAC DE 2009-I B.V. NETHERLANDS
AADDBX.99999.SL.060 GWD Limited BERMUDA
AAE9W5.99999.SL.764 Bualuang Money Market RMF THAILAND
AAGH8E.99999.SL.276 Sparda-Bank Baden-Wuerttemberg eG GERMANY
AAGR6U.99999.SL.438 Konsolidationsanstalt LIECHTENSTEIN
AAGWV3.99999.SL.360 BATAVIA PROTEKSI PRIMA 18 INDONESIA
AAGXH0.99999.SL.136 Monarch Capital Partners Ltd CAYMAN ISLANDS
AAHY1V.99999.SL.158 Pingtung County Farmers' Association TAIWAN
AAH0IZ.99999.SL.136 Diversified Absolute Return Fund CAYMAN ISLANDS
I suggest that you use following array formula:
= IFERROR(INDEX(List,SMALL(IF((INDEX(List,,2,1)=A2)*(INDEX(List,,3,1)=D2),ROW(List)-MIN(ROW(List))+1,""),1),1,1),"N/A")
To enter array formula in Windows use Ctrl+Alt+Enter.
On Mac keyboard use Command+Enter.
Then drag the formula downwards.
In this formula I have used named range List, which is equivalent to your Sheet2!$A$2:$C$99999. Named ranges make complicated formulas more readable and flexible.
If you do not want to use named ranges just replace List with Sheet2!$A$2:$C$99999.
=IFERROR(INDEX(Sheet2!$A$2:$C$99999,SMALL(IF((INDEX(Sheet2!$A$2:$C$99999,,2,1)=A2)*(INDEX(Sheet2!$A$2:$C$99999,,3,1)=D2),ROW(Sheet2!$A$2:$C$99999)-MIN(ROW(Sheet2!$A$2:$C$99999))+1,""),1),1,1),"N/A")
It works if your sheets look as follows:

comparing two columns in excel (VLOOKUP not working)

I have been breaking my head with this problem since morning and I haven't found a solution. Please give your valuable pointers if possible, so that I can try to find the solution.
I basically have two sets of data- an old list and a new list. I wish to compare the new list( comparing name and country together) with an old list, since the new list has a few additional entries. Later on, I would like to create a new list with common entries from both old and new list and add all the new entries below the common ones ( if possible, else I will do that manually later on but I would like Excel to tell me that this is a new entry). Sorry, if this has not been well explained, but maybe the following illustration helps
Old List
Item No. Name Country
1 Apples Italy
3 Banana Spain
4 Grapes Slovakia
5 Pineapple Greece
8 Banana Czech Republic
14 Apples India
23 Pineapple Hungary
19 Peach USA
2 Strawberries France
New List
Item No. Name Country
4 Grapes Slovakia
Mango Pakistan
14 Apples India
Oranges Mexico
19 Peach USA
2 Strawberries France
1 Apples Italy
3 Banana Spain
23 Pineapple Hungary
Avocado Netherlands
Expected Output:
List with common serial No.s based on common names from both lists
Item No.Name Country
4 Grapes Slovakia
14 Apples India
19 Peach USA
2 Strawberries France
1 Apples Italy
3 Banana Spain
23 Pineapple Hungary
Mango Pakistan
Oranges Mexico
Avocado Netherlands
As can be seen in this attachment, I have an old list with Item No., Name and Country. Let's assume that the item numbers have been classified based on some code words. In the second list, there are again Item No.s, Name and Country but some item numbers haven't been filled ( since they are new and have not yet been sorted). Now, I want Excel to compare the names AND countries of both data and provide the common Item No. output if there is a match. If there is no match, then I would like Excel to tell me that this is a new entry. I looked up on various forums and I realized that VLOOKUP command only allows me to search on Name OR Country would give me the common entries of Names/Countries respectively but not Item No.s. Is there any formula that could help me solve this problem?
Just paste the list together, then sort it, and then remove the duplicates. Removing duplicates is built-in into Excel starting from version 2007, you will find it in the Data ribbon (see http://office.microsoft.com/en-001/excel-help/filter-for-unique-values-or-remove-duplicate-values-HP010073943.aspx).
To use VLOOKUP just concatenate Name and Country, for example, B2 & "-" & C2. You can then do a lookup on the concatenated values in your source table:
VLOOKUP(B2 & "-" & C2,NewList!D2:E100,2,False)
This assumes that the concatenated column is in D in your new table, and that you've copied the numbers to column E (VLOOKUP can't look to the right). I put in the dash for readablility and to avoid the chance that a Country ends with a number, unlikely as that might be.

Excel Charts for table with many duplicates

I have a list of names with 1000 entries and maybe 750 unique. There are other attributes, like location and position. Can I create a pivot table that would show me simple stat's like X number of unique people, X number unique in location 1, location 2, location 3, and finally x number of positions in location 1, position 2/location1, position 3/location2...?
Name Location Title
Smith, Bob UK Sales Manager
Smith, Bob UK Plant Manger
Jones, Keith UK Sales Manager
Jones, Keith UK Plant Foreman
White, Derick Denver Sales Manager
Brown, Frank Boston Supply Chain
Black, Jay Denver Sales Manager
Smith, Jeff Denver Sales Manager
Gonzalez, Al UK
Gonzalez, Al UK Staging Area Manager
Bright, Susan Denver Legel Secretary
Bright, Susan Denver Paralegal
Bright, Susan Denver Executive Assistant
Bright, Susan Denver Press Secretary
Alf, Jeff Denver VP, Sales
Green, Burt Boston VP, Sales
Jones, Chuck Denver Plant Foreman
Alten, Cory Denver Sales Manager
Clark, Jerry Boston Plant Foreman
Romo, Tom Denver Sales Manager
You may want to consider using CountifS functions in adjacent columns to the data. For example to count unique people, just create a column (call it column x for this example) and enter =Countif(Column A, A1) and copy down for all the rows. then just enter =countif(Column X, 1) and that should give you the unique names.
You can use CountifS function for more complicated counting logic to answer the other questions.
I have done similar counting of unique entries using pivot tables.
I create a additional column that has a 1 if it is the first occurance of the "key" (ie name). The formula is similar to this: (assume Column A has the "key")
=IF(ROW(A1) = MATCH(A1,A:A,0),1,0)
This formula is then copied down for every row (or if it's a proper table, it's auto copied!)
The idea is that the MATCH returns the row number of the first occurrence of "key". If it is the same as the current row, then count 1. If the values aren't the same, it's a duplicate, so give it a 0 value.
When you then do a pivot table sum on this value, it adds up to the number of unique entries. (ie unique names in a region.)

Resources