Select one value from each column

lakers617

New Member
Joined
Jun 25, 2015
Messages
10
Need excel function or VBA code for this. Please help!

I have around 10 columns. Each column has multiple values but not same number of values.
I want to select one value form each column and put in the last column the combination

Below is a sample of 3 columns. So I want following values in 4 th column - 1XA, 1XB,1XC,1YA,1YB,1YC,2XA,etc

I don't see any excel function. Any VBA code help? I have 10 columns in my excel and one column has the highest number of values (10).

CustomerMaterialDocument
1XA
2YB
3C
4

<tbody>
</tbody>
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Code:
Sub permutation()
Dim a As Long, b As Long, c As Long, i As Long, j As Long, k As Long
With Sheets(1)
    a = .Range("A1", .Cells(Rows.Count, 1).End(xlUp)).Rows.Count
    b = .Range("B1", .Cells(Rows.Count, 2).End(xlUp)).Rows.Count
    c = .Range("C1", .Cells(Rows.Count, 3).End(xlUp)).Rows.Count
    For i = 1 To a
        For j = 1 To b
            For k = 1 To c
                .Cells(Rows.Count, 4).End(xlUp)(2) = .Cells(i, 1).Value & .Cells(j, 2).Value & .Cells(k, 3).Value
            Next
        Next
    Next
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,504
Messages
6,114,020
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top