In your original formula where you have " " replace with a new if:

=IF(MID(A238,5,4)="TEST", IF(A237="CTAG",A236,J237),IF(MID(A238,5,5)="TEST1",A,B))

Where A is what you want to do if that is true and B is when false. Again replace B with another IF statement.

Or if you want the same output for each test you can try:

=IF(OR(MID(A238,5,4)="TEST",IF(MID(A238,5,5)="TEST1",IF(MID(A238,5,3)="TES,IF(MID(A238,5,7)="TEST123"),IF(A237="CTAG",A236,J237)," ")

As long as one of your checks is true then it will move onto the A237 bit.