ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running worksheet function in VBA (https://www.excelbanter.com/excel-programming/284975-running-worksheet-function-vba.html)

jmoffat[_5_]

Running worksheet function in VBA
 
I am trying to run the worksheet function Minverse in VBA using:

result = Application.WorksheetFunction.MInverse(pt_array)

This works ok if pt_array is a range taken from a worksheet

(eg pt_array = range("A1:c3"))


However if I try and incorporate an array directly with VBA

(eg pt_array(1)=1 ; pt_array(2)=2 ... etc)

the function fails.

I guess I need to convert my array to a range somehow - and I'd rather
not write it out to a worksheet and then have to read it back in.

Any Ideas ?


---
Message posted from http://www.ExcelForum.com/


patrick molloy

Running worksheet function in VBA
 
pt_array must be a matrix not a vector. In other words
yuo have it with one dimension when it should have two

pt_array(1,1)=1
pt_array(1,2)= nnn
....
pt_array(1,10)= nnnn
pt_array(2,1)= nnn
pt_array(2,2)= nn
....
pt_array(2,10)=nnn
....
....
pt_array(10,10)=nnn


The advantage of loading the array from a sheet is
obvious
.... unless you're generating the array as a reslt of some
other operation of course.

Patrick Molloy
Microsoft Excel MVP




-----Original Message-----
I am trying to run the worksheet function Minverse in

VBA using:

result = Application.WorksheetFunction.MInverse(pt_array)

This works ok if pt_array is a range taken from a

worksheet

(eg pt_array = range("A1:c3"))


However if I try and incorporate an array directly with

VBA

(eg pt_array(1)=1 ; pt_array(2)=2 ... etc)

the function fails.

I guess I need to convert my array to a range somehow -

and I'd rather
not write it out to a worksheet and then have to read it

back in.

Any Ideas ?


---
Message posted from http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 05:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com