I need to change an output from this code

daniboymu

Board Regular
Joined
Nov 1, 2020
Messages
55
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

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Forum statistics

Threads
1,148,160
Messages
5,745,123
Members
423,927
Latest member
Pra56

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