hello
I need help to show the TOTAL value in textbox2 when run userform . so after search the item in textbox1 and show the data in listbox .it should summing the values in col 5 in listbox and show the result in textbox2
this is my code
thanks
I need help to show the TOTAL value in textbox2 when run userform . so after search the item in textbox1 and show the data in listbox .it should summing the values in col 5 in listbox and show the result in textbox2
this is my code
VBA Code:
Private Sub TextBox1_Change()
If TextBox1.Value = "" Then ListBox1.Clear: Exit Sub
Dim x As Worksheet
ListBox1.Clear
k = 0
For Each x In ThisWorkbook.Worksheets
ss = x.Cells(Rows.Count, 1).End(xlUp).Row
For Each C In x.Range("B2:B" & ss)
b = InStr(C, TextBox1)
If b > 0 Then
ListBox1.AddItem
ListBox1.List(k, 0) = x.Cells(C.Row, 1).Value
ListBox1.List(k, 1) = x.Cells(C.Row, 2).Value
ListBox1.List(k, 2) = x.Cells(C.Row, 3).Value
ListBox1.List(k, 3) = x.Cells(C.Row, 4).Value
ListBox1.List(k, 4) = x.Cells(C.Row, 5).Value
ListBox1.List(k, 5) = x.Cells(C.Row, 6).Value
k = k + 1
End If
Next C
Next x
End Sub