make a bunch of adjustments
This commit is contained in:
parent
85c3269bcc
commit
ba99264fb6
240
fpvt.frm
240
fpvt.frm
@ -16,6 +16,8 @@ Attribute VB_Exposed = False
|
|||||||
Public mod_adjust As Boolean
|
Public mod_adjust As Boolean
|
||||||
Private month() As Variant
|
Private month() As Variant
|
||||||
Private mload() As Variant
|
Private mload() As Variant
|
||||||
|
Private adjust As Object
|
||||||
|
|
||||||
Option Explicit
|
Option Explicit
|
||||||
|
|
||||||
Private Sub cbCancel_Click()
|
Private Sub cbCancel_Click()
|
||||||
@ -28,14 +30,6 @@ Private Sub cbCancel_Click()
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Private Sub cbOK_Click()
|
|
||||||
|
|
||||||
'MsgBox (handler.scenario)
|
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
|
||||||
|
|
||||||
Private Sub chbPlug_Change()
|
Private Sub chbPlug_Change()
|
||||||
|
|
||||||
opvolume.Enabled = Not chbPlug.value
|
opvolume.Enabled = Not chbPlug.value
|
||||||
@ -44,6 +38,16 @@ Private Sub chbPlug_Change()
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Private Sub butAdjust_Click()
|
||||||
|
MsgBox ("adjustment posted")
|
||||||
|
Me.Hide
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Private Sub butCancel_Click()
|
||||||
|
Me.Hide
|
||||||
|
End Sub
|
||||||
|
|
||||||
Private Sub lbMonth_Change()
|
Private Sub lbMonth_Change()
|
||||||
|
|
||||||
Dim i As Long
|
Dim i As Long
|
||||||
@ -85,110 +89,74 @@ Private Sub lbMonth_Change()
|
|||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub opEditPrice_Click()
|
||||||
|
opPlugVol.Enabled = False
|
||||||
|
opPlugPrice.Enabled = False
|
||||||
|
opPlugVol.Visible = False
|
||||||
|
opPlugPrice.Visible = False
|
||||||
|
opPlugPrice.value = True
|
||||||
|
opPlugVol.value = False
|
||||||
|
|
||||||
Private Sub ListBox1_Click()
|
tbFcPrice.Enabled = True
|
||||||
|
tbFcPrice.BackColor = &H80000018
|
||||||
|
tbFcVal.Enabled = False
|
||||||
|
tbFcVal.BackColor = &H80000005
|
||||||
|
tbFcVol.Enabled = False
|
||||||
|
tbFcVol.BackColor = &H80000005
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub opmprice_Click()
|
Private Sub opEditSales_Click()
|
||||||
|
opPlugVol.Enabled = True
|
||||||
|
opPlugPrice.Enabled = True
|
||||||
|
opPlugVol.Visible = True
|
||||||
|
opPlugPrice.Visible = True
|
||||||
|
|
||||||
tbMFVal = Format(CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value) + CDbl(tbMAVal.value), "#,###")
|
tbFcPrice.Enabled = False
|
||||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)), "#,###")
|
tbFcPrice.BackColor = &H80000005
|
||||||
tbMFPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value), "#.000")
|
tbFcVal.Enabled = True
|
||||||
|
tbFcVal.BackColor = &H80000018
|
||||||
|
tbFcVol.Enabled = False
|
||||||
|
tbFcVol.BackColor = &H80000005
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub opmvol_Click()
|
Private Sub opEditVol_Click()
|
||||||
|
opPlugVol.Enabled = False
|
||||||
Dim pchange As Double
|
opPlugPrice.Enabled = False
|
||||||
|
opPlugPrice.value = False
|
||||||
'---------calculate percent change----------------------------------------------------------------------
|
opPlugVol.value = True
|
||||||
pchange = 1 + CDbl(tbMAVal.value) / (CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value))
|
opPlugVol.Enabled = False
|
||||||
'---------add the adjustments together to get the new forecast------------------------------------------
|
opPlugPrice.Enabled = False
|
||||||
tbMFVal = Format(CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value) + CDbl(tbMAVal.value), "#,###")
|
opPlugVol.Visible = False
|
||||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)) * pchange, "#,###")
|
opPlugPrice.Visible = False
|
||||||
tbMFPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value), "#.000")
|
|
||||||
|
|
||||||
|
tbFcPrice.Enabled = False
|
||||||
|
tbFcPrice.BackColor = &H80000005
|
||||||
|
tbFcVal.Enabled = False
|
||||||
|
tbFcVal.BackColor = &H80000005
|
||||||
|
tbFcVol.Enabled = True
|
||||||
|
tbFcVol.BackColor = &H80000018
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub opprice_Click()
|
Private Sub opPlugPrice_Click()
|
||||||
|
calc_val
|
||||||
tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value) + CDbl(tbAdjVal.value), "#,###")
|
|
||||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)), "#,###")
|
|
||||||
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub opvolume_Click()
|
Private Sub opPlugVol_Click()
|
||||||
|
calc_val
|
||||||
Dim pchange As Double
|
|
||||||
|
|
||||||
'---------calculate percent change----------------------------------------------------------------------
|
|
||||||
pchange = 1 + CDbl(tbAdjVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
|
|
||||||
'---------add the adjustments together to get the new forecast------------------------------------------
|
|
||||||
tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value) + CDbl(tbAdjVal.value), "#,###")
|
|
||||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)) * pchange, "#,###")
|
|
||||||
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub tbAdjVal_Change()
|
Private Sub tbFcPrice_Change()
|
||||||
|
If opEditPrice Then calc_price
|
||||||
Dim pchange As Double
|
|
||||||
|
|
||||||
If IsNumeric(tbAdjVal.value) Then
|
|
||||||
'---------calculate percent change----------------------------------------------------------------------
|
|
||||||
pchange = 1 + CDbl(tbAdjVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
|
|
||||||
'---------add the adjustments together to get the new forecast------------------------------------------
|
|
||||||
tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value) + CDbl(tbAdjVal.value), "#,###")
|
|
||||||
'---------if volume adjustment method is selected, scale the volume up----------------------------------
|
|
||||||
If opvolume Then
|
|
||||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)) * pchange, "#,###")
|
|
||||||
Else
|
|
||||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)), "#,###")
|
|
||||||
End If
|
|
||||||
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
|
|
||||||
Else
|
|
||||||
tbFcVal = Format(CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value), "#,###")
|
|
||||||
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)), "#,###")
|
|
||||||
tbFcPrice = Format(CDbl(tbFcVal.value) / CDbl(tbFcVol.value), "#.000")
|
|
||||||
End If
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
|
Private Sub tbFcVal_Change()
|
||||||
Private Sub tbAdjVol_Change()
|
If opEditSales Then calc_val
|
||||||
|
|
||||||
If IsNumeric(tbAdjVol.value) Then
|
|
||||||
tbFcVol = Format(CDbl(tbAdjVol.value) + CDbl(tbBaseVol.value), "#,###")
|
|
||||||
Else
|
|
||||||
tbFcVol = Format(CDbl(tbBaseVol.value), "#,###")
|
|
||||||
End If
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub tbMAVal_Change()
|
Private Sub tbFcVol_Change()
|
||||||
|
If opEditVol Then calc_vol
|
||||||
Dim pchange As Double
|
|
||||||
|
|
||||||
If IsNumeric(tbMAVal.value) Then
|
|
||||||
'---------calculate percent change----------------------------------------------------------------------
|
|
||||||
pchange = 1 + CDbl(tbMAVal.value) / (CDbl(tbMAVal.value) + CDbl(tbMBaseVal.value))
|
|
||||||
'---------add the adjustments together to get the new forecast------------------------------------------
|
|
||||||
tbMFVal = Format(CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value) + CDbl(tbMAVal.value), "#,###")
|
|
||||||
'---------if volume adjustment method is selected, scale the volume up----------------------------------
|
|
||||||
If opmvol Then
|
|
||||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)) * pchange, "#,###")
|
|
||||||
Else
|
|
||||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)), "#,###")
|
|
||||||
End If
|
|
||||||
tbMFPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value), "#.000")
|
|
||||||
Else
|
|
||||||
tbMFVal = Format(CDbl(tbmPAVal.value) + CDbl(tbMBaseVal.value), "#,###")
|
|
||||||
tbMFVol = Format((CDbl(tbMPAVol.value) + CDbl(tbMBaseVol.value)), "#,###")
|
|
||||||
tbMFPrice = Format(CDbl(tbMFVal.value) / CDbl(tbMFVol.value), "#.000")
|
|
||||||
End If
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub UserForm_Activate()
|
Private Sub UserForm_Activate()
|
||||||
@ -232,7 +200,7 @@ Private Sub UserForm_Activate()
|
|||||||
Next i
|
Next i
|
||||||
|
|
||||||
fpvt.tbFcVol.value = Format(CDbl(fpvt.tbBaseVol.value) + CDbl(fpvt.tbPadjVol.value), "#,###")
|
fpvt.tbFcVol.value = Format(CDbl(fpvt.tbBaseVol.value) + CDbl(fpvt.tbPadjVol.value), "#,###")
|
||||||
fpvt.tbFcVal.value = Format(CDbl(fpvt.tbBaseVal.value) + CDbl(fpvt.tbPadjVal.value), "#,###")
|
fpvt.tbFcVal.value = Format(CDbl(fpvt.tbBaseVal.value) + CDbl(fpvt.tbPadjVal.value), "#")
|
||||||
fpvt.tbFcPrice.value = Format(CDbl(fpvt.tbFcVal.value) / CDbl(fpvt.tbFcVol.value), "#.000")
|
fpvt.tbFcPrice.value = Format(CDbl(fpvt.tbFcVal.value) / CDbl(fpvt.tbFcVol.value), "#.000")
|
||||||
|
|
||||||
'---------------------------------------populate monthly-------------------------------------------------------
|
'---------------------------------------populate monthly-------------------------------------------------------
|
||||||
@ -293,3 +261,87 @@ Function co_num(ByRef one As Variant, ByRef two As Variant) As Variant
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
Sub calc_val()
|
||||||
|
|
||||||
|
Dim pchange As Double
|
||||||
|
|
||||||
|
If IsNumeric(tbFcVal.value) Then
|
||||||
|
'calculate percent change
|
||||||
|
pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.value))
|
||||||
|
|
||||||
|
'plug the adjustment required
|
||||||
|
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||||
|
|
||||||
|
|
||||||
|
'---------if volume adjustment method is selected, scale the volume up----------------------------------
|
||||||
|
If opPlugVol Then
|
||||||
|
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.value)) * pchange, "#,###")
|
||||||
|
Else
|
||||||
|
tbFcVol = Format((CDbl(tbPadjVol.value) + CDbl(tbBaseVol.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")
|
||||||
|
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")
|
||||||
|
End If
|
||||||
|
|
||||||
|
'build json
|
||||||
|
Set adjust = JsonConverter.ParseJson("{""scneario"":" & scenario & "}")
|
||||||
|
adjust("type") = "increment"
|
||||||
|
If opPlugVol Then
|
||||||
|
adjust("vp") = "v"
|
||||||
|
Else
|
||||||
|
adjust("vp") = "p"
|
||||||
|
End If
|
||||||
|
adjust("amount") = tbAdjVal
|
||||||
|
adjust("stamp") = Format(Date + time, "yyyy-mm-dd hh:mm:ss")
|
||||||
|
adjust("user") = Application.UserName
|
||||||
|
|
||||||
|
'print json
|
||||||
|
tbJSON = JsonConverter.ConvertToJson(adjust)
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub calc_vol()
|
||||||
|
|
||||||
|
Dim pchange As Double
|
||||||
|
|
||||||
|
If IsNumeric(tbFcVol.value) And tbFcVol <> 0 Then
|
||||||
|
'price should already have been re-calculated to base + prior at this point
|
||||||
|
tbFcVal = Format(CDbl(tbFcPrice.value) * CDbl(tbFcVol.value))
|
||||||
|
|
||||||
|
'calculate percent change
|
||||||
|
'pchange = CDbl(tbFcVal.value) / (CDbl(tbPadjVal.value) + CDbl(tbBaseVal.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")
|
||||||
|
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), "#,###")
|
||||||
|
End If
|
||||||
|
tbFcVal = Format(tbFcVal, "#,###")
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Sub calc_price()
|
||||||
|
|
||||||
|
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")
|
||||||
|
Else
|
||||||
|
tbFcVal = 0
|
||||||
|
tbAdjVal = Format(CDbl(tbFcVal.value) - CDbl(tbBaseVal.value) - CDbl(tbPadjVal.value), "#,###")
|
||||||
|
End If
|
||||||
|
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
|
||||||
|
23
handler.bas
23
handler.bas
@ -1,3 +1,4 @@
|
|||||||
|
Attribute VB_Name = "handler"
|
||||||
Option Explicit
|
Option Explicit
|
||||||
|
|
||||||
Public sql As String
|
Public sql As String
|
||||||
@ -32,33 +33,11 @@ Sub load_fpvt()
|
|||||||
End If
|
End If
|
||||||
Next i
|
Next i
|
||||||
|
|
||||||
If showprice Then
|
|
||||||
fpvt.opvolume.Visible = False
|
|
||||||
fpvt.opprice.Visible = False
|
|
||||||
fpvt.tbAdjPrice.BackColor = &H80000005
|
|
||||||
fpvt.tbAdjVol.BackColor = &H80000005
|
|
||||||
fpvt.tbAdjVal.BackColor = &H80000004
|
|
||||||
fpvt.tbAdjVal.Enabled = False
|
|
||||||
fpvt.tbAdjPrice.Enabled = True
|
|
||||||
fpvt.tbAdjVol.Enabled = True
|
|
||||||
Else
|
|
||||||
fpvt.opvolume.Visible = True
|
|
||||||
fpvt.opprice.Visible = True
|
|
||||||
fpvt.tbAdjPrice.BackColor = &H80000003
|
|
||||||
fpvt.tbAdjVol.BackColor = &H80000003
|
|
||||||
fpvt.tbAdjVal.BackColor = &H80000005
|
|
||||||
fpvt.tbAdjVal.Enabled = True
|
|
||||||
fpvt.tbAdjPrice.Enabled = False
|
|
||||||
fpvt.tbAdjVol.Enabled = False
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
fpvt.Show
|
fpvt.Show
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Function request_adjust(doc As String) As Object
|
Function request_adjust(doc As String) As Object
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
VERSION 1.0 CLASS
|
||||||
|
BEGIN
|
||||||
|
MultiUse = -1 'True
|
||||||
|
END
|
||||||
|
Attribute VB_Name = "Sheet3"
|
||||||
|
Attribute VB_GlobalNameSpace = False
|
||||||
|
Attribute VB_Creatable = False
|
||||||
|
Attribute VB_PredeclaredId = True
|
||||||
|
Attribute VB_Exposed = True
|
||||||
Option Explicit
|
Option Explicit
|
||||||
|
|
||||||
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
|
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
|
||||||
|
Loading…
Reference in New Issue
Block a user