Based on the content of your question, you want to use PIVOT.
Based on the title of your question, I have no idea what you're asking, and you'll have to expand what you've written to at least include some examples.
Edit ->
Having seen your update, you definitely want to use PIVOT. If you do not know what the source data range will be before you pivot, then you can use dynamic SQL to return the result. You can find an example of that in my answer to this question.