Welcome to the Board!
The best thing to do is to get rid of the merged cells. Merged cells are an ABSOLUTE NIGHTMARE for Excel, wreaking all sorts of havoc with things like sorting and VBA.
It is highly, HIGHLY recommend that you get rid of them (most serious programmers will never use them, and many will not even touch any questions dealing with them).
You can probably remove them/clean them up with VBA code.
If you are interested in that, post a small sample of your data, and someone here should be able to help you with that code.