Need a macro

matthewR
5StarLounger
Posts: 627
Joined: 03 Feb 2010, 15:02

Need a macro

Post by matthewR »

In column A, I have Client Number. I sorted on column A and removed the duplicate client numbers where there are duplicates. In Column N, I have a Contact name. For every break in Column A, client number, If there are different contact names, I want to delete all but the first contact name. If they are the same that is ok and not to be removed.

A N
001 Joe Smith
Bill Gates

Remove Bill Gates

A
002 Joe Smith
Joe Smith
Leave it

I only want to remove the rows when there are more than one client number and different names. There could be 3 different names for a client number.

Is this possible? I am trying to do this manually but it is taking forever.

User avatar
sdckapr
3StarLounger
Posts: 392
Joined: 25 Jan 2010, 12:21

Re: Need a macro

Post by sdckapr »

A simple way (no macro needed) would be to in a blank column in Row 2 the formula:
=n2=n1
Copy the comparison down the column for the data range

Then add filters to the range
Filter on the comparison column for FALSE and filter on column A for blank.

Now you are only displaying blank rows in A, which are not equal to the cell above

delete all those rows (or just delete the items in col N if that is what you mean by "remove")
Remove the filters
Delete the comparison column.

Steve
Last edited by sdckapr on 07 Oct 2013, 15:36, edited 2 times in total.

User avatar
sdckapr
3StarLounger
Posts: 392
Joined: 25 Jan 2010, 12:21

Re: Need a macro

Post by sdckapr »

Cross-posted at http://windowssecrets.com/forums/showth ... ed-a-Macro" onclick="window.open(this.href);return false;

Steve

matthewR
5StarLounger
Posts: 627
Joined: 03 Feb 2010, 15:02

Re: Need a macro

Post by matthewR »

It doesn's seem to work. Where there are 2 client numbers that have 2 of the same contact names, the top row has True and the one row that is blank is showing False. If the two or three names are the same, I don't want to remove them.

User avatar
sdckapr
3StarLounger
Posts: 392
Joined: 25 Jan 2010, 12:21

Re: Need a macro

Post by sdckapr »

Could you attach a file with some examples that do not work....

The comparison should be FALSE when the name in the row does NOT match the name above. If you have multiple blank rows, you may have to repeat the comparison, filtering and deleting.

Steve

matthewR
5StarLounger
Posts: 627
Joined: 03 Feb 2010, 15:02

Re: Need a macro

Post by matthewR »

It worked. I was using the wrong calculation. I think I put n3 = n2 instead of n2 = n1. Worked like a charm. Thank you.