Yes, BA Unit B can both Pile In and Consolidate, as they charged that turn, and can do so regardless of whether they are in engagement range of anything. They won't be able to attack anything, however, as all units they charged are destroyed. Even if Eldar unit Z were just 2" away from them, you could pile in to engagement range and consolidate, but they couldn't attack Eldar Unit Z, and Eldar Unit Z can attack the BA.
|