define row/column vector of matrix

Ms.Sigma

New Member
Joined
Mar 1, 2011
Messages
35
Hello all,

In user form, there are some textboxes and they display expected values derived from some other functions. After I get all these values, I need to use them to do further calculation.

For example, there are 5 textboxes, thus, there are 5 values. I need to make these 5 values to be a one row vector or one column vector. How should I define it?

Thanks a lot!!
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Perhaps !!
Rich (BB code):
Code:
[COLOR="Navy"]Sub[/COLOR] MG06Mar51
[COLOR="Navy"]Dim[/COLOR] n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]For[/COLOR] n = 1 To 5
Cells(n, 1) = Me.Controls("TextBox" & n).Object.value
[COLOR="Navy"]Next[/COLOR] n
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0

Ms.Sigma

New Member
Joined
Mar 1, 2011
Messages
35
Thanks for quick response! I tried those code, but it doesn't work.

Maybe I didn't describe my problem very clear at the beginning. Now,I re-explain it;)

Here is the function to calculate the expected value:

Function PVar(VaRs, CMatrix)

Dim vp

vp = Application.Sum(Application.MMult(Application.MMult(VaRs, CMatrix) , Application.Transpose(VaRs))

PVar = Sqr(vp)

End Function

In the macros above, CMatrix is defined by another function, and it works well. VaRs should be the one column vector, and each component of this vector should be the value showed by textbox1, textbox2, etc.

Now, I have values of textboxes. How can I have VaRs?

Thanks again!!
 
Upvote 0

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
I've no real experiance with the MMult function, but playing with your "Pvar" function I find that I do not get a value returned unless the 2 Matrixes are the same shape and size.
So perhaps you need to ensure the textbox values are returned to the sheet as per the other matrix (Shape and size)
Regards Mick
 
Upvote 0

Ms.Sigma

New Member
Joined
Mar 1, 2011
Messages
35
I re-defined my macros.

When the values of all these textboxes are generating, the same values are displayed in worksheet. For example, 5 values of textbox 1 to textbox 5 are also showed in Range ("M1:Q1").

I make VaRs=Range("M1:Q1"), but it still doesn't work.
 
Upvote 0

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
The help file for MMult states among other things:-
The number of columns in array1 must be the same as the number of rows in array2, and both arrays must contain only numbers.

You seem to have 2 rows of 5 cells. That does not seem to meet the criteria.
Mick
 
Upvote 0

Ms.Sigma

New Member
Joined
Mar 1, 2011
Messages
35
Hello,MickG!

I have only one row for these values. ;)

I checked my macros, and I find the problem is the reference of matrix of listbox1.

As I have said in previous thread, another function for generating Cmatrix works well, and the result is displayed in listbox1.

Now, I need this matrix displayed in listbox1 and all values of textbox to calculate another value. I defined Cmatrix=listbox1.list(), but it is wrong. How should I fix this mistake?
 
Upvote 0

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
I'm sorry ,I'm not really the person to help you with this.
I can only state that an error returns with your function unless both matrixes have the same number of rows as columns.
I suggests you look at the Data/layout of the function that works to find why that one works and not the other.
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,191,184
Messages
5,985,175
Members
439,945
Latest member
ospe

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
Top