Stephen_IV
Well-known Member
- Joined
- Mar 17, 2003
- Messages
- 1,177
- Office Version
- 365
- 2019
- Platform
- Windows
Is there a way to shorten this formula? I cannot figure it out. Any help would be appreciated!
VBA Code:
=LET(
unique_vals, UNIQUE(A2:A209),
count_C, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((C2:C209="E") + (C2:C209="P"))))),
count_D, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((D2:D209="E") + (D2:D209="P"))))),
count_E, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((E2:E209="E") + (E2:E209="P"))))),
count_F, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((F2:F209="E") + (F2:F209="P"))))),
count_G, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((G2:G209="E") + (G2:G209="P"))))),
count_H, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((H2:H209="E") + (H2:H209="P"))))),
count_I, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((I2:I209="E") + (I2:I209="P"))))),
count_J, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((J2:J209="E") + (J2:J209="P"))))),
count_K, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((K2:K209="E") + (K2:K209="P"))))),
count_L, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((L2:L209="E") + (L2:L209="P"))))),
count_M, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((M2:M209="E") + (M2:M209="P"))))),
count_N, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((N2:N209="E") + (N2:N209="P"))))),
count_O, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((O2:O209="E") + (O2:O209="P"))))),
count_P, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((P2:P209="E") + (P2:P209="P"))))),
count_Q, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((Q2:Q209="E") + (Q2:Q209="P"))))),
count_R, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((R2:R209="E") + (R2:R209="P"))))),
count_S, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((S2:S209="E") + (S2:S209="P"))))),
count_T, MAP(unique_vals, LAMBDA(val, SUMPRODUCT((A2:A209=val) * ((T2:T209="E") + (T2:T209="P"))))),
HSTACK(unique_vals, count_C, count_D, count_E, count_F, count_G, count_H, count_I, count_J, count_K, count_L, count_M, count_N, count_O, count_P, count_Q, count_R, count_S, count_T)
)