Hello, I have this code to calculate the sum of certain columns on the Listbox and show the result on the Textbox I now need to get the largest and smallest date on the Listbox column 2 and show them on TEXTBOX 7 and TEXTBOX8
Format "mm/dd/yyyy"
Format "mm/dd/yyyy"
VBA Code:
Sub SUM_COL()
Dim Cont As Long
sum = 0: sum1 = 0: sum2 = 0: sum3 = 0: sum4 = 0: sum5 = 0: sum6 = 0: sum7 = 0
Cont = 0
Set F = Sheets("data")
With ListBox1
For r = 0 To .ListCount - 1
Cont = Cont + 1
sum = sum + .List(r, 5)
sum1 = sum1 + .List(r, 6)
sum2 = sum2 + .List(r, 10)
sum3 = sum3 + .List(r, 11)
sum4 = sum4 + .List(r, 12)
sum5 = sum5 + .List(r, 19)
'MIN DATE
sum6 = Application.WorksheetFunction.Min(.List(r, 2))
'MAX DATE
sum7 = Application.WorksheetFunction.Max(.List(r, 2))
Next r
End With
Me.TextBox1.Value = sum
Me.TextBox2.Value = sum1
Me.TextBox3.Value = sum2
Me.TextBox4.Value = sum3
Me.TextBox5.Value = sum4
Me.TextBox6.Value = sum5
Me.TextBox7.Value = sum6
Me.TextBox8.Value = sum7
Me.TextBox9.Value = Cont
End Sub