add scenario to sheet

This commit is contained in:
Trowbridge 2019-03-15 10:44:45 -04:00
parent 67ac7d9cff
commit 75af4275f2
2 changed files with 84 additions and 0 deletions

View File

@ -333,3 +333,70 @@ Sub load_config()
ReDim Preserve handler.adjust(j - 1)
End Sub
Sub month_tosheet(ByRef pkg() As Variant)
Dim i As Integer
Dim sh As Worksheet
Set sh = Sheets("_month")
For i = 0 To 12
'------------volume-------------------
sh.Cells(i + 1, 1) = co_num(pkg(i, 1), 0)
sh.Cells(i + 1, 2) = co_num(pkg(i, 2), 0)
sh.Cells(i + 1, 3) = co_num(pkg(i, 3), 0)
sh.Cells(i + 1, 4) = 0
sh.Cells(i + 1, 5) = co_num(pkg(i, 4), 0)
'------------value----------------------
sh.Cells(i + 1, 11) = co_num(pkg(i, 5), 0)
sh.Cells(i + 1, 12) = co_num(pkg(i, 6), 0)
sh.Cells(i + 1, 13) = co_num(pkg(i, 7), 0)
sh.Cells(i + 1, 14) = 0
sh.Cells(i + 1, 15) = co_num(pkg(i, 8), 0)
'-------------price----------------------
If i > 0 Then
'--prior--
If co_num(pkg(i, 1), 0) = 0 Then
sh.Cells(i + 1, 6) = 0
Else
sh.Cells(i + 1, 6) = pkg(i, 5) / pkg(i, 1)
End If
'--base--
If co_num(pkg(i, 2), 0) = 0 Then
sh.Cells(i + 1, 7) = 0
Else
sh.Cells(i + 1, 7) = pkg(i, 6) / pkg(i, 2)
End If
'--adjust--
If co_num(pkg(i, 3), 0) = 0 Then
sh.Cells(i + 1, 8) = 0
Else
sh.Cells(i + 1, 8) = pkg(i, 7) / pkg(i, 3)
End If
'--current adjust--
sh.Cells(i + 1, 9) = 0
'--forecast--
If co_num(pkg(i, 4), 0) = 0 Then
sh.Cells(i + 1, 10) = 0
Else
sh.Cells(i + 1, 10) = pkg(i, 8) / pkg(i, 4)
End If
End If
Next i
End Sub
Function co_num(ByRef one As Variant, ByRef two As Variant) As Variant
If one = "" Or IsNull(one) Then
co_num = two
Else
co_num = one
End If
End Function

View File

@ -16,6 +16,12 @@ Private sales() As Variant
Private dumping As Boolean
Private vedit As String
Private Sub Worksheet_Activate()
Call Me.load_sheet
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not dumping Then
@ -110,3 +116,14 @@ Sub set_sheet()
dumping = False
End Sub
Sub load_sheet()
units = Sheets("_month").Range("A2:e13").FormulaR1C1
price = Sheets("_month").Range("F2:j13").FormulaR1C1
sales = Sheets("_month").Range("K2:o13").FormulaR1C1
Call Me.set_sheet
End Sub