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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
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
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
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
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
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
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
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,224,521
Messages
6,179,287
Members
452,902
Latest member
Knuddeluff

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