VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "months"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = True
Option Explicit

Private x As New TheBigOne
Private units() As Variant
Private price() As Variant
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

        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()

    units = Range("B6:F17")
    price = Range("H6:L17")
    sales = Range("N6:R17")
      
End Sub

Sub set_sheet()

    dumping = True

    Range("B6:F17") = units
    Range("H6:L17") = price
    Range("N6:R17") = sales
    
    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
