rsquared function in VBA

wishes

New Member
Joined
Apr 16, 2006
Messages
44
Hi

I am looking for some help with the r squared function in VBA
I have a userform with textboxes where X and Y values are entered.
What I am stuck with is how to get the values of the textboxes into the r squared argument.

Here is what I have tried so far.

Code:
Sub test()
theys = UserForm1.TextBox1.Value ,UserForm1.TextBox2.Value,UserForm1.TextBox3.Value
thexs = UserForm1.TextBox4.Value,UserForm1.TextBox5.Value,UserForm1.TextBox6.Value
ans = Application.WorksheetFunction.RSq(theys, thexs)
MsgBox (ans)
End Sub

I just don't know how to get the Y's and X's values into the rsquared function correctly.

Thanks
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi

Give this a try:

Code:
Sub test()
theys = Array(CDbl(UserForm1.TextBox1.Value) ,CDbl(UserForm1.TextBox2.Value),CDbl(UserForm1.TextBox3.Value))
thexs = Array(CDbl(UserForm1.TextBox4.Value),CDbl(UserForm1.TextBox5.Value),CDbl(UserForm1.TextBox6.Value))
ans = Application.WorksheetFunction.RSq(theys, thexs)
MsgBox ans
End Sub
 
Upvote 0
Hi Richard.

Thankyou for your reply, this is exactly what I was trying to do.
I have never seen anything like this before.

Code:
Array(CDbl(UserForm1.TextBox1.Value)

Thank you again.
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,716
Members
448,985
Latest member
chocbudda

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