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?Johannes

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

Next

OrgRow = OrgRow + 1

'Reset Column Counter

OrgCol = 1

Next

End Sub

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

tries.Johannes

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.

Ask Your Question

Weekly Poll