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