From 1cf13e4f5792855a70150a775c5e5112a1e7f4df Mon Sep 17 00:00:00 2001 From: PhilRunninger Date: Mon, 1 Apr 2024 12:22:50 -0400 Subject: [PATCH] Fix rounding of percent change. --- .../shipDateShifter.frm | 19 ++++++++++++------ .../shipDateShifter.frx | Bin 9752 -> 9752 bytes 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Master Template.xlsm_EXPORTS/shipDateShifter.frm b/Master Template.xlsm_EXPORTS/shipDateShifter.frm index 30091b1..e7f47cb 100644 --- a/Master Template.xlsm_EXPORTS/shipDateShifter.frm +++ b/Master Template.xlsm_EXPORTS/shipDateShifter.frm @@ -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, diff --git a/Master Template.xlsm_EXPORTS/shipDateShifter.frx b/Master Template.xlsm_EXPORTS/shipDateShifter.frx index 7b7922894740b8a41ceabc01f9ddc1f57a10b76a..85b8fb986b86592a3eb74f0d00b9b3c23f51cf61 100644 GIT binary patch delta 644 zcmaKpF-QVY7{}jxYUL@WncgXRMO|7Ab-ojXkOterwZ=f>Itjf*&Y-QKr7ij(q9LN7 zu>@&oiH4#rXsDs7mS}EhXo%jsl!T<=ec$){|Nq~E$J@*8Q}id1t$6U-}#OCKnV;tqrY=J*m?b= zpX;rh-T8ZqAsHLs5fdEhAsVig5RuRrLZ}O&joG}pq?ed=6&mJ=f$&pXqMIjH%VpiP z3g8vvJdqM9K?sUs8W-SDymc@WRwVWl2o5BQ^KdU2glW?eicKg-3|1c^8msQ8#*LZi zGBHu(Bx(|(rXd^~cUVaZS>73&cGqA(HgEHLQ|n;@$T&tj%9Nw3n?RK*oPvU~fK|9q5?F&5B|$XQ5Jr9Y8(A{Q A&;S4c delta 663 zcmaJ-JxCj27=FL+j3pNpB__E9bBdlnXG?xALdC)1vWVDj?I>K2m{`o^2v>0uhYs!P z3lch%(m?1aMg$je>sD|`hHl-YQz=dkrSEq=)3`W%?{m-lJ=4LciRb z3#t8nAQ@shHp4~!#=+~b$)@qKT;y&YUD@PT9ZzKwPvj_uBYE79MDbZ9FQf+%)2AJx zB^TWxgV%O_a6kaIhL?hl_T8Jp8B_)Vxy4yuOVqNrPEfO_r&4k_D>aRDqLtHMK?e?N-X+JfFjO zT9=-e_RtK_A#}V7en`KNzy|ysa8=bMr~$4M3jJ=tKdXx(<{MFAyHyL!!^~uvCOPu! tpUDD)wlUR|Xj9!8omq!k*4G+ZmKpd;d&%;6uFaF