I need help with an excel assignment.
Name City
---------------
John London
Maxx NY
Ashley DC
Paris
Solution for this must be:
John-london
John-NY
John-DC
John-Paris
Maxx-london
Maxx-NY
.
.
.
.so on.
Simply I have to add text of all elements in one column to text of all elements in other column. I will appreciate if a solution without macros or VB is provided.
Here's an Array Formula you can use, though you will need to modify the size of the matrix depending on how many entries you have
Assuming Column A is Names and Column B is Cities, you would select 12 cells (3 rows high, 4 columns wide), paste the above formula in the first cell and press
Ctrl + Shift + Enter
to create the array formula.If you want to see a little simpler version to see what it does before the
INDEX
references, check with the same area:Here's a screenshot (with the formula split in 2 lines) of the single formula displaying the output over multiple cells:
This is a simple example in VBA. It is intended to show the concept, not the best practices. Please use it to get you started, and get back here if you need more help, if you want to improve the performances, etc.
The example assumes that the two lists are in
A1:An
andB1:Bm
, and the resulting list goes in columnC
.resulting column formula should be
You can use this formula (start in Row 1 and fill down until you run out of combinations):
I'm using named ranges "L_1" and "L_2" to refer to the first and second lists respectively