Potential Pair Combinations

marcox22

New Member
Joined
Mar 7, 2018
Messages
2
Hi All,
I kindly ask you to help me out on what I'd like to reach.
I have a list of numbers (around 100) and I'd like to get all the potential combinations of sums in pairs.


To simplify:
If I have these three numbers: 1 - 2 - 3, I would like to get the follwing result.


1+1= 2
2+2= 4
3+3= 6
1+2= 3
1+3= 4
2+3= 5


Therefore as output I would like to have the above mentioned results : 2,4,6,3,4,5.


Is there any formula/macro that would allow me to get this output in a larger scale?


Thank you very very much!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
start with this:

Code:
Public Sub aMacro()
Dim colNums As New Collection
Dim i As Integer, j As Integer


  'load all nums from excel list
Range("A1").Select
While ActiveCell.Value <> ""
   colNums.Add ActiveCell.Value
   ActiveCell.Offset(1, 0).Select    'next row
Wend


   'output
Range("D1").Select
For i = 1 To colNums.Count
   For j = 1 To colNums.Count
      ' colNums(i) & "+" & colNums(j) & "=" & colNums(i) + colNums(j)
      ActiveCell.Offset(0, 0).Value = colNums(i)
      ActiveCell.Offset(0, 1).Value = "+"
      ActiveCell.Offset(0, 2).Value = colNums(j)
      ActiveCell.Offset(0, 3).Value = colNums(i) + colNums(j)
      
      ActiveCell.Offset(1, 0).Select    'next row
   Next
Next


Set colNums = Nothing
End Sub
 
Upvote 0
Messaging isnt working...so,
enter VBE, (alt-F11)
if you do not have any modules , menu: insert, module.
paste the code.
yes you can alter the code for your list. Mine just reads down the A column.
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,961
Members
452,539
Latest member
delvey

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