Concatenate all combinations grouped in columns

  • Thread starter midnightcallsrl
  • Start date
M

midnightcallsrl

While doing a SEO job I am stuck on the following - any help is really welcome:

- I have 2 columns with several words;
- I would like to CONCATENATE all the possible combinations of the 2 columns,
- group them in columns by the content of the first column.

Example:
column A: Mr red, Mr green, Ms pruple
Column B: 1, 2

Column C: Mr red1, Mr red2
Column D: Mr Green1, Mr Green2
Column E: Ms Purple1, Ms Purple2

I can manage for the first 2 steps, but I am stuck in the last (grouping..).

Any of you is able to help, perhaps with a Macro?

Thanks,
Alex
 
C

Claus Busch

Hi Alex,

Am Sun, 5 May 2013 09:03:16 -0700 (PDT) schrieb
(e-mail address removed):
Example:
column A: Mr red, Mr green, Ms pruple
Column B: 1, 2

Column C: Mr red1, Mr red2
Column D: Mr Green1, Mr Green2
Column E: Ms Purple1, Ms Purple2

try:

Sub Concatenate()
Dim LRowA As Long, LRowB As Long
Dim i As Long, j As Long
Dim Col As Integer

LRowA = Cells(Rows.Count, "A").End(xlUp).Row
LRowB = Cells(Rows.Count, "B").End(xlUp).Row
Col = 3

For i = 1 To LRowA
For j = 1 To LRowB
Cells(j, Col) = Cells(i, 1) & Cells(j, 2)
Next j
Col = Col + 1
Next i
End Sub


Regards
Claus Busch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top