# Correlation Matrices in Excel

Is there an easy way to get Excel to fill in the upper half of a correlation matrix? I realize that it mirrors the lower half which is why it is left blank, but in order to complete the calculations I am doing I need the entire matrix. I am tired of copying and pasting (transposed).
Thanks
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Hi eanqrist,

Place the cursor on the left top cell of your macro and run following macro from there. It will perform the copy and paste you wish for any matrix dimension

Sub FillMatrix()
a = Selection.Row
Selection.End(xlDown).Select
b = Selection.Row
n = b - a + 1
ActiveCell.Offset(1 - n, 0).Select
For i = 1 To n
For j = i + 1 To n
Selection.Offset(i - 1, j - 1).Value = Selection.Offset(j - 1, i - 1).Value
Next j
Next i
End Sub

Hope this helps,
Geert
0

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Commented:
Sorry, I wrote

>Place the cursor on the left top cell of your macro and run following....

I meaned to write:

Place the cursor on the left top cell of your matrix and run following....

Bye

0
Commented:
########################################################################################################################

Just to look if by doing this I could manipulate the width of the thread
0
Commented:

Yep, it worked, sorry for that
0
Author Commented:
Thanks very much!
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.