Hi all,
In the below command I was getting the sum values of all the values that was displayed in the listbox...I want the command to run as selected values in listbox to get sum and displaying in the textbox but once i run the program it displaying sum all the values displayed in the listbox.. can suggest any solution.
Code
- Private Sub CommandButton1_Click()
- Dim i As Long
- Dim sum As Double
- Dim sum1 As Double
- Dim sum2 As Double
- If Me.ListBox1.Selected(i) = True Then
- With Me
- For i = 0 To Me.ListBox1.ListCount - 1
- sum = sum + Val(Me.ListBox1.List(i, 4))
- sum1 = sum1 + Val(Me.ListBox1.List(i, 5))
- sum2 = sum2 + Val(Me.ListBox1.List(i, 6))
- Next i
- Me.TextBox6.Text = sum & ".00"
- Me.TextBox8.Text = sum1 & ".00"
- Me.TextBox9.Text = sum2 & ".00"
- End With
- End If
- End Sub