Fix rounding of percent change.
This commit is contained in:
parent
ae6b21b197
commit
1cf13e4f57
@ -25,7 +25,6 @@ Private Sub cmdCancel_Click()
|
|||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub cmdOK_Click()
|
Private Sub cmdOK_Click()
|
||||||
'build json
|
|
||||||
Dim adjust As Object
|
Dim adjust As Object
|
||||||
Set adjust = JsonConverter.ParseJson("{""scenario"":" & scenario & ", ""distributions"":[]}")
|
Set adjust = JsonConverter.ParseJson("{""scenario"":" & scenario & ", ""distributions"":[]}")
|
||||||
adjust("scenario")("version") = handler.plan
|
adjust("scenario")("version") = handler.plan
|
||||||
@ -49,7 +48,7 @@ Private Sub cmdOK_Click()
|
|||||||
Set distribution = JsonConverter.ParseJson( _
|
Set distribution = JsonConverter.ParseJson( _
|
||||||
"{""ship_season"":" & selectedSeason & "," & _
|
"{""ship_season"":" & selectedSeason & "," & _
|
||||||
" ""ship_month"": """ & Me.Controls("lblShipMonth" & Format(m, "00")).Caption & """," & _
|
" ""ship_month"": """ & Me.Controls("lblShipMonth" & Format(m, "00")).Caption & """," & _
|
||||||
" ""pct"":" & Val(Replace(lblPctMonth(selectedSeason, m).Caption, "%", "")) / 100 & _
|
" ""pct"":" & Val(RemoveFormat(month.text)) / currentValue & _
|
||||||
"}")
|
"}")
|
||||||
adjust("distributions").Add distribution
|
adjust("distributions").Add distribution
|
||||||
End If
|
End If
|
||||||
@ -62,7 +61,7 @@ Private Sub cmdOK_Click()
|
|||||||
Set distribution = JsonConverter.ParseJson( _
|
Set distribution = JsonConverter.ParseJson( _
|
||||||
"{""ship_season"":" & selectedSeason + 1 & "," & _
|
"{""ship_season"":" & selectedSeason + 1 & "," & _
|
||||||
" ""ship_month"": """ & Me.Controls("lblShipMonth" & Format(m, "00")).Caption & """," & _
|
" ""ship_month"": """ & Me.Controls("lblShipMonth" & Format(m, "00")).Caption & """," & _
|
||||||
" ""pct"":" & Val(Replace(lblPctMonth(selectedSeason + 1, m).Caption, "%", "")) / 100 & _
|
" ""pct"":" & Val(RemoveFormat(month.text)) / currentValue & _
|
||||||
"}")
|
"}")
|
||||||
adjust("distributions").Add distribution
|
adjust("distributions").Add distribution
|
||||||
End If
|
End If
|
||||||
@ -129,6 +128,7 @@ Private Sub cmdOK_Click()
|
|||||||
Call Utils.SHTp_DumpVar(res, shData.Name, i, 1, False, False, True)
|
Call Utils.SHTp_DumpVar(res, shData.Name, i, 1, False, False, True)
|
||||||
shShipments.PivotTables("ptShipments").PivotCache.Refresh
|
shShipments.PivotTables("ptShipments").PivotCache.Refresh
|
||||||
|
|
||||||
|
Unload Me
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub UserForm_Activate()
|
Private Sub UserForm_Activate()
|
||||||
@ -141,6 +141,7 @@ Private Sub UserForm_Activate()
|
|||||||
.BackColor = &H80000018
|
.BackColor = &H80000018
|
||||||
.Enabled = False
|
.Enabled = False
|
||||||
End With
|
End With
|
||||||
|
UpdatePercentages
|
||||||
|
|
||||||
lblSeasonCurrent.Caption = selectedSeason
|
lblSeasonCurrent.Caption = selectedSeason
|
||||||
lblSeasonNext.Caption = selectedSeason + 1
|
lblSeasonNext.Caption = selectedSeason + 1
|
||||||
@ -208,6 +209,13 @@ Private Function Recalculate(updated As MSForms.TextBox) As Boolean
|
|||||||
ApplyFormatting txtSelectedMonth
|
ApplyFormatting txtSelectedMonth
|
||||||
lblWarning.Visible = before > 0
|
lblWarning.Visible = before > 0
|
||||||
|
|
||||||
|
UpdatePercentages
|
||||||
|
|
||||||
|
Recalculate = False ' Success
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Private Sub UpdatePercentages()
|
||||||
|
Dim m As Integer
|
||||||
For m = 1 To 12
|
For m = 1 To 12
|
||||||
If txtMonth(selectedSeason, m).text = "" Then
|
If txtMonth(selectedSeason, m).text = "" Then
|
||||||
lblPctMonth(selectedSeason, m).Caption = ""
|
lblPctMonth(selectedSeason, m).Caption = ""
|
||||||
@ -220,8 +228,7 @@ Private Function Recalculate(updated As MSForms.TextBox) As Boolean
|
|||||||
lblPctMonth(selectedSeason + 1, m).Caption = Format(txtMonth(selectedSeason + 1, m).text / currentValue, "0%")
|
lblPctMonth(selectedSeason + 1, m).Caption = Format(txtMonth(selectedSeason + 1, m).text / currentValue, "0%")
|
||||||
End If
|
End If
|
||||||
Next
|
Next
|
||||||
Recalculate = False ' Success
|
End Sub
|
||||||
End Function
|
|
||||||
|
|
||||||
|
|
||||||
' Remove formatting before editing a textbox. After editing, restore formatting,
|
' Remove formatting before editing a textbox. After editing, restore formatting,
|
||||||
|
|||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user