VBA to compare filtered list to another list

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
761
Office Version
  1. 365
Platform
  1. Windows
Column B has a list of names and column C has a corresponding amount for each name. The length of this list could vary.

Cell F3 contains one of the names, and below that a list of numbers. In this case there are four numbers typed in, but there could be more or fewer.

I'd like to use a VBA macro to return either "Yes" or "No" in cell F1. "Yes" should be returned if the number of amounts, and the values of those amounts, for Tom in column C match the amounts for Tom in column F, in the same order.

In other words, if column B were filtered for Tom, the list of amounts for Tom would be exactly the same as the list beginning in cell F4.

Is there a way to do this with VBA? Thanks!

filter.png
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
You can do that with a simple formula
=IF(SUMIFS(C:C,B:B,F3)=SUM(F4:F100),"Yes","No")
 
Upvote 0
Thanks for helping me out again!

I don't just want to know if the sums equal, which of course they would if both ranges of numbers were exactly the same.

I mainly want to know if the two lists of numbers, column C with only Tom and column F, are exactly the same in the same order.

So 1, 2, 3, 4 in column C and 1, 2, 4, 3 in column F would return "No". Likewise, 1, 2, 3, 4 in column C and 1, 2, 2, 5 would return a "No".

Thanks, CJ
 
Upvote 0
Ok, what version of Excel are you using?
Please update your account details to show this, as it affects what functions you have available.
Thanks
 
Upvote 0
Ok, thanks for that, please update your account details to show that you are using 365.
I'm currently having to repair Office as Outlook blew up, but will post a solution shortly.
 
Upvote 0
Ok, how about
+Fluff New.xlsm
ABCDEFG
1YesNoNo
2
3Joe18TomTomTom
4Mac14202020
5Tom20121612
6Joe9161216
7Mac18202021
8Joe14
9Joe18
10Tom12
11Joe13
12Joe11
13Tom16
14Ned17
15Ned17
16Ned10
17Tom20
18Joe20
Data
Cell Formulas
RangeFormula
E1:G1E1=IF(TEXTJOIN(",",1,IF($B$3:$B$20=E3,$C$3:$C$20,""))=TEXTJOIN(",",1,E$4:E$10),"Yes","No")
 
Upvote 0
This will do exactly what I need (THANKS!), but I am having trouble getting it to work.

If I enter your formula in E1, or in any cell in row 1 or 2, it returns #VALUE!. If I enter it anywhere in row 3 or further down, it returns "No" when it should be "Yes." E1 is selected in the screen shot below.

I tried breaking down your formula into parts, in red and blue in my screen shot. It does not seem that on my sheet it is pulling only Tom's amounts from column C. All cells are formatted as "General".

I'm not sure how else to troubleshoot. CJ

Excel_issue.png
 
Upvote 0
Oops, I keep forget to mention this.
In your version of Xl you will need to confirm the formula with Ctrl Shift Enter & not just Enter.
 
Upvote 0
Works perfectly! Thanks you so much for all the help. This formula will really streamline the project I am working on!
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,557
Members
449,088
Latest member
davidcom

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