From column to row

See JamesK's answer in this thread: Dynamic Pivots