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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Richard Schollar

MrExcel MVP
Joined
Apr 19, 2005
Messages
23,707
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
 

wishes

New Member
Joined
Apr 16, 2006
Messages
44
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,389
Messages
5,836,972
Members
430,464
Latest member
nickburrett

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