Hi, I'm complete beginner to VBA, and I need to create a spreadsheet that needs to inverse varies matrix, how do I use this code? For example, my SourceCell is at cell C1 (may be any size of square matrix) and cell A1 is a number that tells the size of this matrix it needs to inverse, and DestCell is at C100. A1 and C1 will change when data changes and I want C100 to automatically updated as a result of this, would the code be something below?
VBA Code:
Sub InverseArea()
Dim SourceCell As Variant, DestCell As Variant
Dim MatrixSize As Long
Dim SourceRange As Range, DestRange As Range
SourceCell = "C1"
MatrixSize = "A1"
DestCell = "C100"
Set SourceRange = Range(SourceCell & ":" & Range(SourceCell).Offset(MatrixSize - 1, MatrixSize - 1).Address)
Set DestRange = Range(DestCell & ":" & Range(DestCell).Offset(MatrixSize - 1, MatrixSize - 1).Address)
DestRange.Select
Selection.FormulaArray = "=MINVERSE(" & SourceRange.Address(0, 0) & ")"
End Sub