Finding all possible combinations of 2 sums

togenmoser

New Member
Joined
Mar 21, 2024
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone, I need some help here please.
Using vba macro, I want excel to find all possible combinations of 2 cells sum from each row of 5 cells that sum up to any of the target values of cells h1:r1.
And then set all-round thick border for all 2 cells that sum up to any of the target values.
And also set same border colour for cells that sum up to the same target value.
My worksheet has multiple rows and each row has 5 cells. Rows are separated by an empty cell.
I used the find sum pairs but excel keeps skipping some of the cells that has sum total equal to a target value.
Eg. Cells d33 and e33 has sum total of 83 but excel ignored it.
Any effort will be much appreciated.
Thanks.

DLF FORECAST.xlsm
ABCDEFGHIJKLMNOPQRSTUVWXY
1826355146914513796151118771326912483
2
3267541648348513771216347075257241845225
454532960563987325351302015672754128937
529634902147823716422619446144375901164
6726461950469434482212271889303617864
7403769760201073441241744331823628908756
81288656370598571529035113624426914123516
9316644184542619377580761185666379514753
109085621049846979186855771979706965152426
1172128058558812560838134910867053853043
1235164519174764625608387623688141906545
132015183859216916373379709041406566633868
1464778166375161365513657636816312016142
157277803761568573683939542575602036498830
16114378690688866572673722356635829267689
1715874070837944384230894325823433685082
186576785722675268412761122514903418585521
19192784412222324301581478738522945618
2059237262552316434795659921466850452815
217154202475157017771642434170682963263317
22534781510378633351129627049412514841051
2317317067752686123913630345019171078507
24505574588125891946371735128063327511780
251786731121617627658799013543273217043
2637905785915404589827249905377480681310
276226673359827313525144666082695660544145
28498043155512015163231125637685918122861
29486375884132875771804336805735881524361
307570465526592423454943238646354518048
315621827616642654415746846557824668811
32783113114565759141235458939783829273319
338582156870206165638265117225277937363473
SUN. SPECIAL
Cell Formulas
RangeFormula
H1H1=SUM(B1,C1)
I1I1=SUM(B1,D1)
J1J1=SUM(B1,E1)
K1K1=SUM(B1,F1)
L1L1=SUM(C1,D1)
N1N1=SUM(C1,E1)
O1O1=SUM(C1,F1)
P1P1=SUM(D1,E1)
Q1Q1=SUM(D1,F1)
R1R1=SUM(E1,F1)
Named Ranges
NameRefers ToCells
'SUN. SPECIAL'!Print_Area='SUN. SPECIAL'!$C$1:$BC$106N1:O1, L1, H1
 
Hi, I need help to improve the code above.
I want excel to ignore all cells that are exact duplicates of cells B1:F1.
I also want it to only pair cells that are within the criteria of + or - 1 to 10 of cells B1 to F1 and has a sum total that equals any of the cells of h1 to r1.
Eg. Even though cells i5 and L5 sum up to cell Q1, both cells are not within the criteria of + or - 1 to 10 of any of the cells B1 to F1.
Cells b14 and d14 are within the criteria of+1 and -1 of cells B1 and c1.
And then cells i8 and k8 are also within the criteria of -3 and +3 of cells B1 and D1.
I would like Excel to only pair cells that are within the specified criteria and also sum up to any of the cells of H1:R1.
Thanks a lot in anticipation of your assistance.
 
Upvote 0

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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