I'm taking a cell that people can enter data into, and trying to interpret it in several ways. They can enter a code with between 7 and 20 characters. Depending upon the length, and the leading character, I want it to strip out the excess data and leave just a serial #. The different possibilities of data that people can enter are as follows:
7 character serial #
8 character serial #
8 character serial # with leading L
9 character serial # with leading D or L
10 character serial #
11 character serial # with leading M
12 character serial #
13 character serial # with leading M
20 character serial # with 12 leading useless characters
I've managed to create multiple IF statements that individually can identify each of these, but I'm trying to combine them into a single formula so that one cell shows JUST a valid serial #, after editing the entered data from a separate cell. I've managed to mix a couple of them, but the more AND and/or OR statements I add, the more confusing, and more likely to break the formula gets.
Is there an easier/better way to do this?
As an addendum, thanks to Special Instance:

I have removed the attempted formulae above, and recreated 4 formulae, posted below, which does each of the above necessary steps, but they're separate, and I need them together:
=IF(AND(LEN(A2)=8,(LEFT(A2,1)="L")), RIGHT(A2,7),A2)
=IF(AND(OR(LEFT(A2,1)="D",LEFT(A2,1)="L"),LEN(A2)=9),RIGHT(A2,8),A2)
=IF(OR(LEN(A2)=11,LEN(A2)=13),RIGHT(A2,LEN(A2)-1),A2)
=IF(NOT(LEN(A2)=20),A2,RIGHT(A2,8))
