Dear, Thanks for explaining your requirements further! I have reviewed your problem and created two complex formulas: one for populating training and course codes and another for shift times.
To develop formulas that would fulfil your goal, I used the IFERROR, TEXTJOIN, TRANSPOSE, FILTER, FIND...