get things calcuating, need to do sales based adjust

This commit is contained in:
Paul Trowbridge 2019-03-14 17:13:25 -04:00
parent 2f56c991a7
commit 67ac7d9cff

View File

@ -14,6 +14,81 @@ Private units() As Variant
Private price() As Variant Private price() As Variant
Private sales() As Variant Private sales() As Variant
Private dumping As Boolean Private dumping As Boolean
Private vedit As String
Private Sub Worksheet_Change(ByVal Target As Range)
If Not dumping Then
If Not Intersect(Target, Range("E6:E17")) Is Nothing Then Call Me.mvp_adj
If Not Intersect(Target, Range("F6:F17")) Is Nothing Then Call Me.mvp_set
If Not Intersect(Target, Range("K6:K17")) Is Nothing Then Call Me.mvp_adj
If Not Intersect(Target, Range("L6:L17")) Is Nothing Then Call Me.mvp_set
'If Not Intersect(Target, Range("Q6:Q17")) Is Nothing Then Call Me.ms_adj
'If Not Intersect(Target, Range("R6:R17")) Is Nothing Then Call Me.ms_set
End If
End Sub
Sub mvp_set()
Dim i As Integer
Call Me.get_sheet
For i = 1 To 12
If units(i, 5) = "" Then units(i, 5) = 0
If price(i, 5) = "" Then price(i, 5) = 0
units(i, 4) = units(i, 5) - (units(i, 2) + units(i, 3))
price(i, 4) = price(i, 5) - (price(i, 2) + price(i, 3))
sales(i, 5) = units(i, 5) * price(i, 5)
sales(i, 4) = sales(i, 5) - (sales(i, 2) + sales(i, 3))
Next i
set_sheet
End Sub
Sub mvp_adj()
Dim i As Integer
Call Me.get_sheet
For i = 1 To 12
If units(i, 4) = "" Then units(i, 4) = 0
If price(i, 4) = "" Then price(i, 4) = 0
units(i, 5) = units(i, 4) + (units(i, 2) + units(i, 3))
price(i, 5) = price(i, 4) + (price(i, 2) + price(i, 3))
sales(i, 5) = units(i, 5) * price(i, 5)
sales(i, 4) = sales(i, 5) - (sales(i, 2) + sales(i, 3))
Next i
set_sheet
End Sub
Sub ms_set()
Dim i As Integer
Call Me.get_sheet
For i = 1 To 12
units(i, 4) = units(i, 5) - (units(i, 2) + units(i, 3))
price(i, 4) = price(i, 5) - (price(i, 2) + price(i, 3))
sales(i, 5) = units(i, 5) * price(i, 5)
sales(i, 4) = sales(i, 5) - (sales(i, 2) + sales(i, 3))
Next i
set_sheet
End Sub
Sub get_sheet() Sub get_sheet()
@ -35,29 +110,3 @@ Sub set_sheet()
dumping = False dumping = False
End Sub End Sub
Sub calc_adjust_vp()
Dim i As Integer
Call Me.get_sheet
For i = 1 To 12
If units(i, 4) = "" Then units(i, 4) = 0
If price(i, 4) = "" Then price(i, 4) = 0
units(i, 4) = units(i, 5) - (units(i, 2) + units(i, 3))
price(i, 4) = price(i, 5) - (price(i, 2) + price(i, 3))
sales(i, 5) = units(i, 5) * price(i, 5)
sales(i, 4) = sales(i, 5) - (sales(i, 2) + sales(i, 3))
Next i
set_sheet
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
If Not dumping Then Call Me.calc_adjust_vp
End Sub