Skip to content

Instantly share code, notes, and snippets.

@machkouroke
Created October 24, 2023 20:55
Show Gist options
  • Save machkouroke/6e621f27d69b8344b63979803069a1e4 to your computer and use it in GitHub Desktop.
Save machkouroke/6e621f27d69b8344b63979803069a1e4 to your computer and use it in GitHub Desktop.
Diagonale function in excel
Option Explicit
Option Base 1
Function Diag(matrix() As Variant) As Variant
Dim i As Integer, n As Integer
Dim D() As Variant
n = UBound(matrix, 1)
ReDim D(n, 1)
For i = 1 To n
D(i, 1) = matrix(i, i)
Next i
Diag = D
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment