schmidthead
New Member
- Joined
- Nov 3, 2018
- Messages
- 4
Full disclosure: I'm a finance guy in Oil & Gas and I use Excel for modeling purposes. Basically I'm looking for a non-array formula and non-VBA UDF formula that can accomplish the below:
[TABLE="width: 270"]
<tbody>[TR]
[TD]Month[/TD]
[TD]Wells[/TD]
[TD]Production[/TD]
[TD]Total Production[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]16,500[/TD]
[TD="align: right"]181,500[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]11,939[/TD]
[TD="align: right"]119,391[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9,529[/TD]
[TD="align: right"]95,290[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8,013[/TD]
[TD="align: right"]72,121[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]6,962[/TD]
[TD="align: right"]62,655[/TD]
[/TR]
</tbody>[/TABLE]
I need a formula that will take the most recently drilled wells (11 in Month 5) and multiply it by the initial production of 16,500. The second most recently drilled wells (10 in Month 4) would be multiplied by 11,939, and so on. I can calculate the lumpsum production using SUMPRODUCT, OFFSET and ROW, but I really need the monthly production instead of the lumpsum. I have a nice UDF that works but my employer frowns upon VBA. I'd prefer not to use arrays either. Is there anyone on here that can help? I will buy you a steak dinner in Houston if you can solve this. I'm posting the VBA below if that helps.
[TABLE="width: 270"]
<tbody>[TR]
[TD]Month[/TD]
[TD]Wells[/TD]
[TD]Production[/TD]
[TD]Total Production[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]16,500[/TD]
[TD="align: right"]181,500[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD="align: right"]9[/TD]
[TD="align: right"]11,939[/TD]
[TD="align: right"]119,391[/TD]
[/TR]
[TR]
[TD="align: right"]3[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]9,529[/TD]
[TD="align: right"]95,290[/TD]
[/TR]
[TR]
[TD="align: right"]4[/TD]
[TD="align: right"]10[/TD]
[TD="align: right"]8,013[/TD]
[TD="align: right"]72,121[/TD]
[/TR]
[TR]
[TD="align: right"]5[/TD]
[TD="align: right"]11[/TD]
[TD="align: right"]6,962[/TD]
[TD="align: right"]62,655[/TD]
[/TR]
</tbody>[/TABLE]
I need a formula that will take the most recently drilled wells (11 in Month 5) and multiply it by the initial production of 16,500. The second most recently drilled wells (10 in Month 4) would be multiplied by 11,939, and so on. I can calculate the lumpsum production using SUMPRODUCT, OFFSET and ROW, but I really need the monthly production instead of the lumpsum. I have a nice UDF that works but my employer frowns upon VBA. I'd prefer not to use arrays either. Is there anyone on here that can help? I will buy you a steak dinner in Houston if you can solve this. I'm posting the VBA below if that helps.
Code:
Function SumRevProduct(R1 As Range, R2 As Range) As Variant
Dim i As Integer
If R1.Cells.Count <> R2.Cells.Count Then GoTo ErrHandler
If R1.Rows.Count > 1 And R1.Columns.Count > 1 Then GoTo ErrHandler
If R2.Rows.Count > 1 And R2.Columns.Count > 1 Then GoTo ErrHandler
For i = 1 To R1.Cells.Count
SumRevProduct = SumRevProduct + _
R1.Cells(IIf(R1.Rows.Count = 1, 1, i), _
IIf(R1.Rows.Count = 1, i, 1)) * _
R2.Cells(IIf(R2.Rows.Count = 1, 1, R2.Cells.Count + 1 - i), _
IIf(R2.Rows.Count = 1, R2.Cells.Count + 1 - i, 1))
Next i
Exit Function
ErrHandler:
SumRevProduct = "Input Error"
End Function
Last edited by a moderator: