Excel has a built-in function that removes duplicates, but often you need to be more clever about what stays and what goes. Here’s how to do it.