worksheetfunction.index array form

SBF12345

Well-known Member
Joined
Jul 26, 2014
Messages
614
I am working with the lines:

Code:
ArrX = Application.WorksheetFunction.Index(X, 0, 2)
    ArrTemp = Application.WorksheetFunction.Index(TempSample, 0, 2)
DistanceMeasure = (1 - Application.WorksheetFunction.Correl(ArrX, ArrTemp)) * 100

I would like to be able to run a simple correlation using arrays with a variable length of objects defined by worksheet inputs and dim as variant. My goal is to be able to run the correlation using all the values in the variant X and variant TempSample. Both have the same number of objects.

what is the correct syntax to do so?

when I do the correlation calculation long hand my values are different. Thanks!
 
Last edited:

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Code:
For gg = 1 To NumObs    
    ArrX(gg) = Application.WorksheetFunction.Index(X, gg, 2)
    ArrTemp(gg) = Application.WorksheetFunction.Index(TempSample, gg, 2)
    ArrX1(gg) = Application.WorksheetFunction.Index(X, gg, 3)
    ArrTemp1(gg) = Application.WorksheetFunction.Index(TempSample, gg, 3)
    
    Next gg

I added this code and it seems to be loading the arrays fine.
 
Upvote 0

Forum statistics

Threads
1,225,743
Messages
6,186,778
Members
453,371
Latest member
HMX180

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