Use VSTACK with other functions?

smking204

New Member
Joined
Jan 28, 2021
Messages
41
Office Version
  1. 365
Platform
  1. Windows
I just discovered VSTACK, and I love the concept, but I'm running into problems using it.

for instance, in K1 I have
=FILTER(VSTACK(A2:A35,B2:B35,C2:C35,D2:D35), VSTACK(A2:A35,B2:B35,C2:C35,D2:D35)<>"")
and this works as expected

and in L1 I have
=UNIQUE(FILTER(K1#,COUNTIF(K1#,K1#)>1))
and this works as expected

but when I try to combine them in one formula, replacing "K1#" with the formula in K1, like this
=UNIQUE(FILTER(FILTER(VSTACK(A2:A35,B2:B35,C2:C35,D2:D35), VSTACK(A2:A35,B2:B35,C2:C35,D2:D35)<>""),COUNTIF(FILTER(VSTACK(A2:A35,B2:B35,C2:C35,D2:D35), VSTACK(A2:A35,B2:B35,C2:C35,D2:D35)<>""),FILTER(VSTACK(A2:A35,B2:B35,C2:C35,D2:D35), VSTACK(A2:A35,B2:B35,C2:C35,D2:D35)<>""))>1))
I get the error saying, "there's a problem with this formula." (I did try toggling the VSTACK arguments to absolute, as well as relative, with no better results.)

Similarly, I have a conditional formatting rule
=MATCH(A2,UNIQUE(FILTER($A$2:$A$35,COUNTIF($A$2:$A$35,$A$2:$A$35)>1)),0)=1
that works as expected, but when I try to replace $A$2:$A$35 with a simple VSTACK, like this
=MATCH(A2,UNIQUE(FILTER(VSTACK($A$2:$A$35,$B$2:$B$35,$C$2:$C$35,$D$2:$D$35),COUNTIF(VSTACK($A$2:$A$35,$B$2:$B$35,$C$2:$C$35,$D$2:$D$35),VSTACK($A$2:$A$35,$B$2:$B$35,$C$2:$C$35,$D$2:$D$35))>1)),0)=1
I get the same error.

What am I missing?

Thanks!
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I think this is caused by Excel treating ranges and arrays as different things, such that a range and an array are not interchangeable. For example, COUNTIF accepts ranges but absolutely will not work with arrays, and I think VSTACK produces an array, which explains why COUNTIF is returning an error. You would have to come up with an alternative way to achieve what COUNTIF does, and that's not a lot of fun.

If you can give us same sample data for copying and pasting, I might be able to help, but I'm not the best at coming up with alternatives to things like COUNTIF. I have done it before, but it was a lot of trial and error.
 
Upvote 1
I think this is caused by Excel treating ranges and arrays as different things, such that a range and an array are not interchangeable. For example, COUNTIF accepts ranges but absolutely will not work with arrays, and I think VSTACK produces an array, which explains why COUNTIF is returning an error. You would have to come up with an alternative way to achieve what COUNTIF does, and that's not a lot of fun.

If you can give us same sample data for copying and pasting, I might be able to help, but I'm not the best at coming up with alternatives to things like COUNTIF. I have done it before, but it was a lot of trial and error.
That is correct. Alternatively, you can use =COUNT(FILTER())
 
Upvote 1
As has been said, countifs needs a range. How about
Excel Formula:
=LET(a,TOCOL(A2:D35,,1),f,FILTER(a,a<>""),UNIQUE(FILTER(f,MAP(f,LAMBDA(m,SUM(--(f=m))))>1)))
 
Upvote 1
Ok, cool. So I don't have a solution yet, but I'm glad the problem is identified. It's strange, because it seems like a key benefit of VSTACK is to take an array and turn it into a range. Maybe I'm understanding those terms wrong. I'm interested in Fluff's suggestion, but I don't want to use it without understanding it, and I won't have time to parse it for a while. I'm content to use my workaround, with extra columns, until I can get my head around a substitute for COUNTIF. Thanks, y'all!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,221,525
Messages
6,160,326
Members
451,637
Latest member
hvp2262

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