How do you convert rows to columns or columns to row in Excel while using formulas?

You can use the TRANSPOSE function, entering it as an Array function. So if you have something in A2 and A3, you could select C2 and D2 and type the following function:

=TRANSPOSE(A2:A3)

Instead of pressing Enter, press Ctrl-Shift-Enter and it will enter the formula into the two cells, C2 and D2, and transpose the values. You can apply the same principle to larger ranges. There are also other ways of doing it, like using the INDIRECT function to reference a cell and get its value.