Question

The user (me) will input between 3 and 20 data points for two variables on Sheet1...

The user (me) will input between 3 and 20 data points for two variables on Sheet1 starting in cells A2 and B2 (your program should work if I input 3, 4, 5, … , or 20 data points). Column A will contain the values for variable x and column B will contain the values for variable y.

Graphical User Interface

Create a UserForm on Sheet1 that contains the following controls:

A Run button will be used to execute a macro that obtains data from the worksheet. The data will be used to calculate a0, a1, r, and the percentage probability. These four values will be output to four TextBoxes on the UserForm.

A fifth TextBox will tell the user if the relationship between the x and y data is "significant" or "not significant".

A Clear button will clear all five TextBoxes.

A Quit button will close the UserForm.

Also create a button on Sheet1 that will load the UserForm.

Executing the Program

When the user clicks the Run button on the UserForm, your program will perform the following tasks:

1) Call a Sub procedure named GetInput that obtains the x and y values from Sheet1 and stores the data in a 2D array named xyvalues.

2) Call a Sub procedure named CalcLine that calculates the coefficients for the best-fit line (a0 and a1) using the data in xyvalues.

3) Call a Function procedure named CalcR that calculates the correlation coefficient (r) using the data in xyvalues.

4) Call a Function procedure named CalcPerProb that determines the percentage probability using the values of r and N, and the values of rO in Table C.

Note: Store the values from Table C in Sheet3 before running the code as you will need to access those values in CalcPerProb. You likely will need to interpolate between values of rO. See the end of the Background section or the Testing section for examples of how to do this.

5) Call a Sub procedure named GiveOutput that outputs a0, a1, r, the percentage probability, and whether the correlation is significant to the five TextBoxes.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

open excel sheet and press alt+F11 to open a vb page
Here go to insert and choose user form to open an user form
take 3 buttons for RUN, CLOSE and CLEAR
take 5 text box to display 4 values and the significance relationship


create a button in spread sheet and write a below code to open user form

Private Sub CommandButton1_Click()
UserForm1.Show
End Sub

Microsoft Visual Basic - Book1.xlsx - [Book1.xlsx - UserForm1 (UserForm)] 쑤 File Edit View Insert Format Debug Run lools Add-

Microsoft Visual Basic- Book1.xlsx-Usertorm 1 (Code)] View Insert Format Debug Run Iools Add-Ins Window Help Type a que ect (

Microsoft Visual BasiC - BookT.xlsx - Modulel (Code le Edit View Insert Format Debug Run Iools Add-Ins Window Help VBAProject

define all these sub procedures in module


write a sub program to RUN button
1. to read x and y column


Private Sub GetInput()
   Dim X.col As Integer
   Dim Y.col As Integer
  
   X = 1
   Y = 2

   Dim X As Integer
   Dim Y As Integer
   Dim rowcounter As integer

   rowcounter = 0
' to move downwards
   rowcounter = rowcounter + 1

   'to check if we hit last row
   X = Sheets("Sheets1").Cells(rowcounter, X.col).Value
   If X = "" Then
       rowcounter = 3
   End If  

   'to extract value
   X = Sheets("Sheets1").Cells(rowcounter, X.col).Value
   Y = Sheets("Sheets1").Cells(rowcounter, Y.col).Value

End Sub


to clear form

Sub ClearForm()

For j = 1 To 5
    UserForm1.Controls("TextBox" & j).Value = ""
Next j

End Sub


to close all

Private Sub cmdClose_Click()
    'Close UserForm.
    Unload Me
End Sub

to calculate coefficient


Sub CalcR()

Dim r As Integer
r =CORREL( B3:B20, A3:A20 )
TextBox3.Value = r
End Sub


to calculate propability

Sub Calp()

Dim P As Integer
Dim Avg As Integer

Avg = "=AVERAGE(A1:A2)"

P = NORM.DIST(A3:A20,Avg,r, TRUE)
TextBox4.Value = P
End Sub

Add a comment
Know the answer?
Add Answer to:
The user (me) will input between 3 and 20 data points for two variables on Sheet1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT