update monthly button controls
This commit is contained in:
parent
699d0fbb2e
commit
6ad0c69c33
86
fpvt.frm
86
fpvt.frm
@ -202,6 +202,29 @@ Private Sub tbFcVol_Change()
|
||||
If opEditVol Then calc_vol
|
||||
End Sub
|
||||
|
||||
'--------------------------------monthly buttons--------------------------------------
|
||||
|
||||
Private Sub opmPrice_Click()
|
||||
calc_mval
|
||||
End Sub
|
||||
|
||||
Private Sub opmVol_Click()
|
||||
calc_mval
|
||||
End Sub
|
||||
|
||||
Private Sub tbmfPrice_Change()
|
||||
If opEditPriceM Then calc_mprice
|
||||
End Sub
|
||||
|
||||
Private Sub tbmfVal_Change()
|
||||
If opEditSalesM Then calc_mval
|
||||
tbMFVal.value = Format(CDbl(tbMFVal.value), "#,###")
|
||||
End Sub
|
||||
|
||||
Private Sub tbmfVol_Change()
|
||||
If opEditVolM Then calc_mvol
|
||||
End Sub
|
||||
|
||||
Private Sub UserForm_Activate()
|
||||
|
||||
Dim sp As Object
|
||||
@ -224,6 +247,8 @@ Private Sub UserForm_Activate()
|
||||
|
||||
'---show existing adjustment if there is one----
|
||||
fpvt.mod_adjust = False
|
||||
fpvt.tbPadjVol.Text = 0
|
||||
fpvt.tbPadjVal.Text = 0
|
||||
|
||||
For i = 1 To sp("package")("totals").Count
|
||||
Select Case sp("package")("totals")(i)("order_season")
|
||||
@ -330,6 +355,7 @@ Sub calc_val()
|
||||
tbAdjPrice = 0
|
||||
'tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((tbBaseVal + tbPadjVal) / (tbBaseVol + tbPadjVol)), "#.000")
|
||||
End If
|
||||
tbFcVal = Format(CDbl(tbFcVal), "#,##0")
|
||||
|
||||
'build json
|
||||
Set adjust = JsonConverter.ParseJson("{""scneario"":" & scenario & "}")
|
||||
@ -391,40 +417,40 @@ Sub calc_mval()
|
||||
|
||||
Dim pchange As Double
|
||||
|
||||
If IsNumeric(tbFcVal.value) Then
|
||||
If IsNumeric(tbMFVal.value) Then
|
||||
'calculate percent change
|
||||
pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
|
||||
pchange = CDbl(tbMFVal.value) / (CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value))
|
||||
|
||||
'plug the adjustment required
|
||||
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
|
||||
|
||||
|
||||
'---------if volume adjustment method is selected, scale the volume up----------------------------------
|
||||
If opPlugVol Then
|
||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)) * pchange, "#,###")
|
||||
If opmvol Then
|
||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)) * pchange, "#,###")
|
||||
Else
|
||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)), "#,###")
|
||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)), "#,###")
|
||||
End If
|
||||
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
|
||||
tbAdjVol = Format(tbFcVol - (CDbl(tbBaseVol) + CDbl(tbPadjVol)), "#,###")
|
||||
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
|
||||
tbMFPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value), "#.000")
|
||||
tbMAVol = Format(tbMFVol - (CDbl(tbMBaseVol) + CDbl(tbMPAVol)), "#,###")
|
||||
tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((CDbl(tbMBaseVal.value) + CDbl(tbmPAVal.value)) / (CDbl(tbMBaseVol.value) + CDbl(tbMPAVol.value))), "#.000")
|
||||
Else
|
||||
'tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value), "#,###")
|
||||
tbAdjVol = Format((CDbl(tbFcVol.value) - CDbl(tbBaseVol.value) - CDbl(tbPadjVol.value)), "#,###")
|
||||
tbAdjPrice = 0
|
||||
'tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((tbBaseVal + tbPadjVal) / (tbBaseVol + tbPadjVol)), "#.000")
|
||||
'tbMFVal = Format(CDbl(tbMPAVal.value) + CDbl(tbMBaseVal.value), "#,###")
|
||||
tbMAVol = Format((CDbl(tbMFVol.value) - CDbl(tbMBaseVol.value) - CDbl(tbMPAVol.value)), "#,###")
|
||||
tbMAPrice = 0
|
||||
'tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((tbMBaseVal + tbMPAVal) / (tbMBaseVol + tbMPAVol)), "#.000")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Sub calc_mprice()
|
||||
|
||||
If IsNumeric(tbFcPrice.value) And tbFcPrice.value <> 0 Then
|
||||
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value), "#,###")
|
||||
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
|
||||
If IsNumeric(tbMFPrice.value) And tbMFPrice.value <> 0 Then
|
||||
tbMFVal = Format(CDbl(tbMFPrice.value) * CDbl(tbMFVol.value), "#,###")
|
||||
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
|
||||
tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((CDbl(tbMBaseVal.value) + CDbl(tbmPAVal.value)) / (CDbl(tbMBaseVol.value) + CDbl(tbMPAVol.value))), "#.000")
|
||||
Else
|
||||
tbFcVal = 0
|
||||
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||
tbMFVal = 0
|
||||
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
|
||||
End If
|
||||
|
||||
End Sub
|
||||
@ -433,23 +459,23 @@ Sub calc_mvol()
|
||||
|
||||
Dim pchange As Double
|
||||
|
||||
If IsNumeric(tbFcVol.value) And tbFcVol <> 0 Then
|
||||
If IsNumeric(tbMFVol.value) And tbMFVol <> 0 Then
|
||||
'price should already have been re-calculated to base + prior at this point
|
||||
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value))
|
||||
tbMFVal = Format(CDbl(tbMFPrice.value) * CDbl(tbMFVol.value))
|
||||
|
||||
'calculate percent change
|
||||
'pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
|
||||
'pchange = CDbl(tbMFVal.value) / (CDbl(tbMPAVal.value) + CDbl(tbMBaseVal.value))
|
||||
|
||||
'plug the adjustment required
|
||||
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||
tbAdjVol = Format(tbFcVol - (CDbl(tbBaseVol) + CDbl(tbPadjVol)), "#,###")
|
||||
tbAdjPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value) - ((CDbl(tbBaseVal.value) + CDbl(tbPadjVal.value)) / (CDbl(tbBaseVol.value) + CDbl(tbPadjVol.value))), "#.000")
|
||||
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
|
||||
tbMAVol = Format(tbMFVol - (CDbl(tbMBaseVol) + CDbl(tbMPAVol)), "#,###")
|
||||
tbMAPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value) - ((CDbl(tbMBaseVal.value) + CDbl(tbmPAVal.value)) / (CDbl(tbMBaseVol.value) + CDbl(tbMPAVol.value))), "#.000")
|
||||
Else
|
||||
tbFcVal = 0
|
||||
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||
tbAdjPrice = Format((tbBaseVal + tbPadjVal) / (tbBaseVol + tbPadjVol), "#.000")
|
||||
tbAdjVol = Format(-CDbl(tbBaseVol.value) - CDbl(tbPadjVol.value), "#,###")
|
||||
tbMFVal = 0
|
||||
tbMAVal = Format(CDbl(tbMFVal.value) - CDbl(tbMBaseVal.value) - CDbl(tbmPAVal.value), "#,###")
|
||||
tbMAPrice = Format((tbMBaseVal + tbmPAVal) / (tbMBaseVol + tbMPAVol), "#.000")
|
||||
tbMAVol = Format(-CDbl(tbMBaseVol.value) - CDbl(tbMPAVol.value), "#,###")
|
||||
End If
|
||||
tbFcVal = Format(tbFcVal, "#,###")
|
||||
tbMFVal = Format(tbMFVal, "#,###")
|
||||
|
||||
End Sub
|
||||
|
Loading…
Reference in New Issue
Block a user