0
votes

I have 2 columns in excel:

name

AAA

BBB

CCC

and Number

1

2

3

I need in the next column to have combination of all the values in both columns:

CombColumn

AAA1

AAA2

AAA3

BBB1

BBB2

BBB3

CCC1

CCC2

CCC3

How do I do this in Excel?

2

2 Answers

1
votes

If VBA is ok then you can accomplish it with the following code:

Option Explicit

Sub Combine()
Dim rowA As Long, rowB As Long, rowC As Long

Range("C:C").ClearContents

rowC = 2

rowA = 2
Do While Range("A" & rowA).Value <> ""
    rowB = 2
    Do While Range("B" & rowB).Value <> ""
        Range("C" & rowC).Value = Range("A" & rowA).Value & Range("B" & rowB).Value
        rowB = rowB + 1
        rowC = rowC + 1
    Loop
    rowA = rowA + 1
Loop

End Sub

Note that code has no error checking where your actual number of values may produce more than maximum rows.

1
votes