Public ChangeFlag As Boolean
Public Filled As Variant
Private Sub cboMonth_Change()
'This skips this Macro when the Userform is first activated
If ChangeFlag = True Then GoTo Quit
'This is required to store the row numbers of the data on the sheet
Pos = Split("6,11,14,23,25,27", ",")
'Is this row empty?
If Filled(cboMonth.ListIndex) = 0 Then
'Fill Row
Filled(cboMonth.ListIndex) = 1
For Count = 0 To 5
'Load the Textbox
Me.Controls("Textbox" & Count + cboMonth.ListIndex * 6 - 5).Value = Sheets(1).Cells(Pos(Count), cboMonth.ListIndex + 1).Value
'Add the New Data to the Summing Text Box at the bottom of the Userform
T1 = Me.Controls("Textbox" & 73 + Count).Value + Sheets(1).Cells(Pos(Count), cboMonth.ListIndex + 1).Value
Me.Controls("Textbox" & 73 + Count).Value = T1
Next
Else
'Clear Row
Filled(cboMonth.ListIndex) = 0
For Count = 0 To 5
'Load the Textbox
Me.Controls("Textbox" & Count + cboMonth.ListIndex * 6 - 5).Value = 0
'Subtract the New Data from the Summing Text Box at the bottom of the Userform
T1 = Me.Controls("Textbox" & 73 + Count).Value - Sheets(1).Cells(Pos(Count), cboMonth.ListIndex + 1).Value
Me.Controls("Textbox" & 73 + Count).Value = T1
Next
End If
Quit:
End Sub
Private Sub UserForm_Initialize()
'This is my database to log which months have been added to the Userform
Filled = Split("0,0,0,0,0,0,0,0,0,0,0,0", ",")
ChangeFlag = True
cboMonth.List = Array("Select", "JANUARY", "FEBRUARY", "MARCH", "APRIL", "MAY", "JUNE", "JULY", "AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER")
cboMonth.ListIndex = 0
ChangeFlag = False
End Sub
Bookmarks