MINVERSE()-- How to change array size?

tolearn1977

New Member
Joined
Mar 6, 2014
Messages
3
Hi I am working on a spreadsheet where I want to use built-in MINVERSE() function. However, my array (matrix) size can vary from 2*2 to 50*50. I am going to be using a square matrix; however the size will vary depending on the problem. Is it even possible to use a formula that will 'dynamically' change array size? Or this will require VBA coding? If so, would you be able to provide a sample code ?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hi,

Not sure I understand. So, basically, you just want some code to take away the trouble of you having to manually select the appropriately-sized destination range in order to commit the array formula?

Regards
 
Upvote 0
Hi I am working on a spreadsheet where I want to use built-in MINVERSE() function. However, my array (matrix) size can vary from 2*2 to 50*50. I am going to be using a square matrix; however the size will vary depending on the problem. Is it even possible to use a formula that will 'dynamically' change array size? Or this will require VBA coding? If so, would you be able to provide a sample code ?

That's correct, I'm looking to be able to program Excel so it adjusts array size as matrix changes & then computes inverse using MINVERSE().
Regards
 
Upvote 0
Perhaps:

Code:
Sub InverseArea()

Dim SourceCell As Variant, DestCell As Variant
Dim MatrixSize As Long
Dim SourceRange As Range, DestRange As Range

SourceCell = InputBox("Reference of top-left cell of Source Matrix")
MatrixSize = InputBox("Rows/Columns in Source Matrix")
DestCell = InputBox("Reference of top-left cell of Destination Matrix")

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


Regards
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top