Its the same as you are doing at the moment for the Y axis, you just do it for the Z axis as well.
In a nutshell:
Edit. Ah StevieG beat me too it. Looks like he has a slightly better approach although aligning Y and Z seems to give similar values?
In a nutshell:
Tformvector 0,1,0,entity1,0 Aligntovector entity2,tformedx(),tformedy(),tformedz(),2 Tformvector 0,0,1,entity1,0 Aligntovector entity2,tformedx(),tformedy(),tformedz(),3
Edit. Ah StevieG beat me too it. Looks like he has a slightly better approach although aligning Y and Z seems to give similar values?