| I figured it out. I ended up coding it in Excel VBA. For anyone interested, here is what I ended up with:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim NPN As Double, Sale As Long, CoverPrice As Currency, Draw As Long, Promo As Currency, x As Long
x = 2
Do Until x = 20
If x = 10 Or x = 11 Then GoTo nextx
NPN = Worksheets("Sheet1").Cells(42, x)
Sale = Worksheets("Sheet1").Cells(32, x)
CoverPrice = Worksheets("Sheet1").Cells(4, x)
Draw = Worksheets("Sheet1").Cells(6, x)
Promo = Worksheets("Sheet1").Cells(41, x)
Select Case Worksheets("Sheet1").Cells(42, x)
Case Is < 1
Do Until NPN >= Worksheets("Sheet1").Range("A44")
Sale = Sale + 1
NPN = (((CoverPrice * (Sale) * (1 - 0.5)) - ((Sale * CoverPrice) * 0.04) - (Draw * 0.3) - (Promo))) / Sale
Loop
Case Is > 1
Do Until NPN <= Worksheets("Sheet1").Range("A44")
Sale = Sale - 1
NPN = (((CoverPrice * (Sale) * (1 - 0.5)) - ((Sale * CoverPrice) * 0.04) - (Draw * 0.3) - (Promo))) / Sale
Loop
End Select
Worksheets("Sheet1").Cells(43, x) = Sale
nextx:
x = x + 1
Loop
End Sub |