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
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

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.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,307
Messages
5,600,869
Members
414,411
Latest member
Snowmanaus

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