UDF needed! Reverse Range/Array Order, then SUMPRODUCT

mbp257

New Member
Joined
Feb 9, 2015
Messages
11
I need help creating a UDF to add multiple projects together at discrete points in their life cycle. Each project has the same production forecast.

Please see table below (btw, this is my first time posting on this forum so please let me know if another format is more helpful)

A few notes:
• Column A contains a typical production amount
• Column B contains the schedule or number of projects per period
• Column C represents what linking the cells manually looks like
• Column D contains an excel formula and works correctly but is confusing for others at my company, hence the desire to create a clean, two-argument function

What I imagine the UDF needs to do is first reverse one of the ranges in column A or B, then apply a SUMPRODUCT or equivalent code.

ABCD
1'Type' AmountScheduleManualFormula
21001100100
39009090
4802280280
5701=B2*A5+B3*A4+B4*A3+B5*A2=SUMPRODUCT(A$2:A5,
N(OFFSET($B$2:$B5,
ROWS($B$2:$B5)-
ROW($B$2:$B5)+
ROW($B$2)-1,0)))

<tbody>
</tbody>

Appreciate the help!
 
A little more compact...
Code:
Function RevSumProduct(Rng1 As Range, Rng2 As Range) As Variant
  RevSumProduct = Evaluate(Replace("SUMPRODUCT(" & Rng1.Address & ",N(OFFSET(@,ROWS(" & _
                  "@)-ROW(@)+ROW(" & Rng2(1).Address & ")-1,0)))", "@", Rng2.Address))
End Function

Thank you Rick, I originally tried doing it in a similar way but was spinning my wheels and using WorksheetFunction.
 
Upvote 0

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,523
Messages
6,125,315
Members
449,218
Latest member
Excel Master

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