Combining values from destignated cells

Brew

Well-known Member
Joined
Sep 29, 2003
Messages
1,569
How do I create a macro or formula that look at the values in H28:J31 table and list every possible combination of each number value within the H column with the I column and the J column and produce the results starting
in H34:J34.

example 1:
H28=0
I28=4
J28=7
J29=9

Result
H34:j34=047
H35:J35=049

example 2:
H28=0
H29=1
I28=4
J28=7
J29=9

Result
H34:j34=047
H35:J35=049
H36:J36=147
H37:J37=149
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

P Sitaram

Well-known Member
Joined
Jun 24, 2003
Messages
1,974
Try this:

Code:
Sub CombHIJ()
    Dim h As Integer, i As Integer, j As Integer
    Dim Hcells As Range, ICells As Range, JCells As Range
    Dim StRg As Range
    
    Set StRg = [h34]
    Set Hcells = Range("H28:" & [h32].End(xlUp).Address)
    Set ICells = Range("I28:" & [i32].End(xlUp).Address)
    Set JCells = Range("J28:" & [j32].End(xlUp).Address)
    
    For h = 1 To Hcells.Cells.Count
        For i = 1 To ICells.Cells.Count
            For j = 1 To JCells.Cells.Count
                StRg = Hcells.Cells(h)
                StRg.Offset(0, 1) = ICells.Cells(i)
                StRg.Offset(0, 2) = JCells.Cells(j)
                Set StRg = StRg.Offset(1, 0)
            Next j
        Next i
    Next h
    
            
End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,122,463
Messages
5,596,284
Members
414,051
Latest member
tabecker

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