reduce 2 formulas into one

excelNewbie22

Well-known Member
Joined
Aug 4, 2021
Messages
510
Office Version
  1. 365
Platform
  1. Windows
hi!
can i reduce the formula in j4 to something i'm trying in j9?
i want to shorten the process cause i have a few thousands to test like this one
test
CDEFGHIJKLMNOPQRSTU
212345221234561516171822
3239101112
456151617182
5reduce
6it
7to
8this?
9#VALUE!
test
Cell Formulas
RangeFormula
K2:U2K2=LET(t,VSTACK(C2:H2,C4:H4),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))
J4J4=SUM(--(COUNTIF(K2#,C3:H3)>0))
J9J9=SUM(--(COUNTIF(LET(t,VSTACK(C2:H2,C4:H4),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i)))),C3:H3)>0))
Dynamic array formulas.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
How about
Excel Formula:
=SUM(SIGN(COUNTIFS(C3:H3,UNIQUE(SORT(HSTACK(C2:H2,C4:H4),,,1),1))))
 
Upvote 0
yet thanks again fluff,
i forgot to mention,
that sometimes i combine vertical and horizontally,
and unique don't work with both of them,
and then it count duplicates too,
anyway to solve it?


test
CDEFGHIJKLMNOPQRST
212345612345615161718
3239101112
456151617182
52343566982reduce
6it
7to
8this?
94
test
Cell Formulas
RangeFormula
K2:T2K2=LET(t,VSTACK(C2:H2,C4:H4),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),TRANSPOSE(UNIQUE(SORT(i))))
J4J4=SUM(--(COUNTIF(K2#,C3:H3)>0))
J9J9=SUM(SIGN(COUNTIFS(C3:H3,UNIQUE(SORT(HSTACK(C2:H2,C4:D5),,,1),1))))
Dynamic array formulas.
 
Upvote 0
i forgot to mention,
You have a habit of doing that. In future please make it clear exactly what you are trying to do to begin with.
Try
Excel Formula:
=SUM(SIGN(COUNTIFS(C3:H3,UNIQUE(SORT(HSTACK(C2:H2,TOROW(C4:D5)),,,1),1))))
 
Upvote 0
Solution
You have a habit of doing that. In future please make it clear exactly what you are trying to do to begin with.
i know, not intentionaly, i'm really trying not to waste any of your time, and really aprriciated all your help

Excel Formula:
=SUM(SIGN(COUNTIFS(C3:H3,UNIQUE(SORT(HSTACK(C2:H2,TOROW(C4:D5)),,,1),1))))
this works, but not to sound ungrateful, is there any easier way to write all the ranges together without separated them inside the formula?
if not, this perfect too
 
Upvote 0
meaining this:
Excel Formula:
HSTACK(C2:H2,TOROW(C4:D5)
i want, if possible, to write them like that:
Excel Formula:
c2:h2,c4:d5,g2:g5
and etc
 
Upvote 0
No you can't do that as they are not all the same size/shape.
 
Upvote 0
i kept trying combining the formula from my first post,
and i think i got it?
can you check and tell if this is ok?
Excel Formula:
=SUM(SIGN(COUNTIFS(C3:H3,UNIQUE(SORT(HSTACK(LET(t,VSTACK(C2:H2,C4:D5,D4:D5),r,ROWS(t),s,SEQUENCE(r*COLUMNS(t),,0),rs,MOD(s,r)+1,cs,INT(s/r)+1,i,INDEX(t,rs,cs),UNIQUE(SORT(i))))),,))))
although there's some duplicate formulas inside like sort and unique
 
Upvote 0

Forum statistics

Threads
1,214,838
Messages
6,121,885
Members
449,057
Latest member
Moo4247

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