Is there a way to make Exel rearrange the order of letters in a cell, so that no matter what it says, the capital letter will always come first? (The cells contain formulas, and they need to stay intact, but the cells, or what's showed in the cells needs to be rearranged).

An example of a row of cells is this (every letter is in one cell separately)

A a b b C c d D E E F F g g

The A's need to be sorted amongst themselves, the b's amongst themselves, and so on, so that I get this:

A a b b C c D d E E F F g g (either in one merged cell, or in separate cells)

THOUGH, in a couple of cells I will have "ToY" or "toY" and in this case, it needs to sort them only by the T's and let the rest follow as it is (the Y is always in capital and needs to be at the end).

Is it possible to to this by an "if"-formula or something and not by macros?

I could also merge the cells that need to be sorted (so that we from the beginning have "aA" in one cell etc.), if it's easier to sort it that way. Though, having "toYToY" in a cell like this I guess might complicate things, won't it?