I need to change an output from this code

daniboymu

Board Regular
Joined
Nov 1, 2020
Messages
54
Office Version
  1. 2019
Platform
  1. Windows
Hi guys! I need help with 2 things with this code
this code gives me the residuals from a linear regression, I need to change to the standard residuals instead


VBA Code:
Sub testRegression()
 Dim sh As Worksheet, celRes As Range, lastRowR As Long, rngDel As Range
 Dim rngTarg As Range, rngDat As Range, rngRet As Range, arrRes
 
 Set sh = ActiveSheet
 Set rngTarg = sh.Range("A2:A201") 'the target range
 Set rngDat = sh.Range("B2:B201")  'values to be processed
 Set rngRet = sh.Range("G2")       'where to return (Regress function)
 
 
 Application.Run "ATPVBAEN.XLAM!Regress", rngTarg, rngDat, False, _
                False, , rngRet, True, False, False, False, , False
        
   Set rngDel = Selection  'the returned range area is selected and
                           'take advantage of this aspect
   'find the cell keeping the string "Residuals":
   Set celRes = rngDel.Find(What:="Residuals", After:=rngRet, _
                LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=False)
   If Not celRes Is Nothing Then
       'determine the last row of the "Residuals" column:
       lastRowR = sh.Cells(sh.Rows.Count, celRes.Column).End(xlUp).Row
       'put "Residuals" values in an array (header included):
       arrRes = sh.Range(celRes, sh.Cells(lastRowR, celRes.Column)).Value
       rngDel.Clear        'clear the initial returned range
     With rngRet.Offset(-1, -1)
        'drop the array values at once:
        .Resize(UBound(arrRes), UBound(arrRes, 2)).Value = arrRes
        .Select
     End With
   End If
End Sub
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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