Creating symmetric matrix in excel

May 11, 2008 at 07:56:42
Specs: OS X 10.4.11, 1.5 GHz PowerPC G4

I have half of a symmetric matrix (from the diagonal up) and
would like to mirror all cells across the diagonal so that I
have a symmetric matrix.
Does anyone here know how to do that?


See More: Creating symmetric matrix in excel

Report •

May 11, 2008 at 17:26:43

It's hard to tell if this works without seeing your original data, but make a backup copy and try this code.

This code assumes that your matrix starts in A1.

It also assumes you have a 9 x 9 matrix. Change the value (9) next to the variable "Size" to match the size of your matrix.

Please let me know how it works out for you.

Sub Build_Matrix()
'Initial Size of Matrix
Size = 9
'Initialize Loop Counter
Cntr = 1
'Initial Counters for Original Data
OrgCol = 1
OrgRow = 1
'Copy Original Data Into Blank Cells
For NewRow = Size To 2 Step -1
'Reduce Column Count For Each Row
Cntr = Cntr + 1
For NewCol = Size To Cntr Step -1
Cells(NewRow, NewCol) = _
Cells(OrgRow, OrgCol)
OrgCol = OrgCol + 1
OrgRow = OrgRow + 1
'Reset Column Counter
OrgCol = 1
End Sub

Report •

May 11, 2008 at 21:15:54

hm. doesn't seem to be doing anything, but let me try it
again. I'm new to this, so sometimes it just takes a couple


Report •

May 12, 2008 at 06:30:47

As I said in my response, it's hard to write this type of code unless you know the exact layout of the original data. The code, as written, expects the matrix to start in a specific cell (A1) and be of a certain size.

I've sent you an e-mail address via private message. If you want to send me a copy of the workbook, I'll see if I can alter the code so it works for you.

Report •

Related Solutions

Ask Question