Find Rows that have a different value

lmoran89

New Member
Joined
Apr 9, 2019
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
This sounds like it should be simple, but I am struggling. Thank you in advance

I have 2 columns of data similar to the below (but 44,000 rows). First column is an account number, second is an identifier. I need to identify the where an account number has both a 2 and 1.

2122102
2122102
2122102
2122102
2122101
2122101
2122101
2122101

<colgroup><col><col></colgroup><tbody>
</tbody>
 

Some videos you may like

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

BlueHornet

Active Member
Joined
Apr 13, 2012
Messages
338
Welcome to the board.

Yeah, this is an ugly formula, for sure. Interesting problem, though. Assuming your Account values start at A1, then:
=IFERROR( IF( AND( FIND( "1", A1), FIND( "2", A1)), "both", "?"), IFERROR( IF( FIND( "1", A1), "1", "??"), IFERROR( IF( FIND( "2", A1), "2", "???"), "neither")))
 
Last edited:

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
Welcome to the Board!

All things being equal, I think this is something that is probably easier accomplished in Microsoft Access, through a "Grouped" and a "Totals" Query. Access may handle that amount of data a little more efficiently too.
However, I realize that you may not have access to Access. If you do, though, let me know, and I can probably help you get what you need.
 

lmoran89

New Member
Joined
Apr 9, 2019
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
Joe4 - Agreed this is something that should be in Access. I had already loaded it, but your help is appreciated
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Let's say the table named is "Table1" and the field names are "AccountNumber" and "Identifier", and the possible value for Identifier are the numeric values 1 and 2.
Then, go to Query Design, change to SQL View, and paste this query code in:
Code:
SELECT AccountNumber
FROM Table1
GROUP BY AccountNumber
HAVING (Sum(IIf([Identifier]=1,1,0))>0) AND (Sum(IIf([Identifier]=2,1,0))>0);
This should return all AccountNumbers who have both 1 and 2.
 

lmoran89

New Member
Joined
Apr 9, 2019
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
Thank you. I'm getting the "Enter Parameter Value" on the Identifier field though. The field was initially text, but changed the data type to number, but still getting that message
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Whenever you see that, and you didn't set a parameter, it typically means you have a typo in the field name (in this case, the field name you are using in the query here does not exactly match the field name in the table).
 
Last edited:

lmoran89

New Member
Joined
Apr 9, 2019
Messages
12
Office Version
  1. 2013
Platform
  1. Windows
Got it!

Thank you so much for your help
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
You are welcome.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,464
Messages
5,596,288
Members
414,052
Latest member
Dual Showman

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
Top