Create a diagonal matrix in Excel?
Solved
lola8
Posted messages
2
Status
Member
-
Nadia -
Nadia -
Hello,
I have a 37x1 vector, which is a column of 37 rows in Excel, and I would like each element of this vector to be on the diagonal of a 37x37 square matrix with zeros around it. I think I need to use a macro, but how?
thanks in advance
I have a 37x1 vector, which is a column of 37 rows in Excel, and I would like each element of this vector to be on the diagonal of a 37x37 square matrix with zeros around it. I think I need to use a macro, but how?
thanks in advance
3 answers
-
no one needs a macro
I name my vector vector
I start my matrix at c1
the formula is IF(ROW()=COLUMN()-2,INDEX(vector,ROW(),1),0) -
Hello,
Suggestion:
Sub Matrice() Dim Boucle, Position As Integer Dim ValeurTMP As Variant For Boucle = 0 To 36 Range("A" & (Boucle + 1)).Select ValeurTMP = ActiveCell.Offset(0, 0).Value For Position = 0 To 36 If (Boucle = Position) Then ActiveCell.Offset(0, Position).Value = ValeurTMP Else ActiveCell.Offset(0, Position).Value = 0 End If Next Position Next Boucle End Sub
Lupin
--
~The essential is invisible to the eye~
~One sees clearly only with the heart~ -
Hello,
I have an Excel 2007 list with two columns (A, B) and 635 rows. I need to create a square matrix in order to study a network.
I have read all of the EXCEL help for more than 50 hours of work, nothing. I don’t know how to program.
Thanks in advance,
Best regards