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

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

JLGWhiz

Well-known Member
Joined
Feb 7, 2012
Messages
12,979
Office Version
  1. 2013
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,426
Messages
5,837,162
Members
430,480
Latest member
iangessey

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
Top