Remove row set based on compare

projectile

Board Regular
Joined
Dec 14, 2007
Messages
193
Hello

I have this extract from msquery , and cannot find a way to exclude customers that have both to codes against their client record, SPQ & FUP for a particular date range. I cannot get the query to work, so think it best to return the figures to excel, and run a compare macro on the table.


Is it possible to do the following;

run a compare on the client column and activity column;;

If a client has has both a SPQ & FUP entry on different rows, then remove all instances of client row, then continue this down the sheet, so that all clients with both codes are removed.

e.g. if clients no. 003212 has both codes SPQ & FUP , then remove entire rows for 003212. i.e. in example below, 4 rows for INternational Ltd would be removed. In the example below, the entire rows in yellow should be removed, based on criteria above.


hope this makes sense.


 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
Hi,

Would this work:

D2 = B2&C2 (copy down)
E2 =IF(ISNA(IF(C2="SPQ",MATCH(B2&"FUP",D:D,0),IF(C2="FUP",MATCH(B2&"SPQ",D:D,0)))),"","delete") - copy down

Then filter on column E for "delete" & delete.
 

projectile

Board Regular
Joined
Dec 14, 2007
Messages
193
Is it possible to add another criteria to this formula , so that if a client has code SPQ and new code JOB, and regardless of FUP to mark for deletion?

Hope this makes sense.



Hi,

Would this work:

D2 = B2&C2 (copy down)
E2 =IF(ISNA(IF(C2="SPQ",MATCH(B2&"FUP",D:D,0),IF(C2="FUP",MATCH(B2&"SPQ",D:D,0)))),"","delete") - copy down

Then filter on column E for "delete" & delete.
 

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
Hi,

Could you post another example table with new condition?

Cheers
 

projectile

Board Regular
Joined
Dec 14, 2007
Messages
193


in this example , companies London Designs, Westfields, Northways should be removed (yellow area).


In essence the condition is something like this;


If a client has SPQ without a FUP and/or JOB then remove. or if client has FUP and/or JOB with no SPQ, then remove

hope this makes sense.

I tried to modify your formula but could figure out how to add the nested if else statement
 

projectile

Board Regular
Joined
Dec 14, 2007
Messages
193
Can anyone help on this other condition?
 

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
sorry for mate - to be honest I was a bit stumped at 1st.

This looks horrible & someone can probably offer better option - maybe through code but this should work for now

=IF(ISNA(IF(ISNA(IF(C2="JOB","delete",IF(C2="SPQ",MATCH(B2&"FUP",D:D,0),IF(C2="FUP",MATCH(B2&"SPQ",D:D,0))))),IF(C2="SPQ",MATCH(B2&"JOB",D:D,0),IF(C2="FUP",MATCH(B2&"JOB",D:D,0))),IF(C2="JOB","delete",IF(C2="SPQ",MATCH(B2&"FUP",D:D,0),IF(C2="FUP",MATCH(B2&"SPQ",D:D,0)))))),"","delete")

Cheers.
 

projectile

Board Regular
Joined
Dec 14, 2007
Messages
193
Hi Danny.

Is doesn't appear to be marking clients with just FUP, appart from that the formula works.

Is it possible to get that added in?
 

Dannyh1

Well-known Member
Joined
Nov 18, 2009
Messages
1,144
Hi - don't no if I'm over complicating things here

Just to be clear - are the only items that should remain have only SPQ?
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,105,996
Messages
5,508,644
Members
408,689
Latest member
SamSan78

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top