Forecast Match and Index in VBA

chenyu768

New Member
Joined
May 25, 2011
Messages
21
I'm trying to simplify some really long formulas in my model by creating some custom functions. I've cleaned up a lot but there's this forecast with offset and match that's throwing me off.

here's the formula

=FORECAST(AE1264,OFFSET('Data Table Dynamic'!$AC$4,MATCH(AE1264,'Data Table Dynamic'!$AB$4:$AB$23,-1)-1,0,3),OFFSET('Data Table Dynamic'!$AB$4,MATCH(AE1264,'Data Table Dynamic'!$AB$4:$AB$23,-1)-1,0,3)))

There's actually 4 of those per cell that's looking at differnt tables so as you can see it gets really long and confusing.

i tried simplfy it by using this

Function LT_Inj(inv, DT_Inv, DT_Inj_Cap, DT_rng)




LT_Inj = WorksheetFunction.Forecast(inv, WorksheetFunction.Offset(DT_Inj_Cap, WorksheetFunction.Match(inv, DT_rng, -1) - 1, 0, 3), WorksheetFunction.Offset(DT_Inv, WorksheetFunction.Match(inv, DT_rng, -1) - 1, 0, 3))


but it's giving me an error.

what am i doing wrong here and also is there a better way than using worksheetFunction?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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