abdelfattah
Well-known Member
- Joined
- May 3, 2019
- Messages
- 1,503
- Office Version
- 2019
- 2010
- Platform
- Windows
hi
actually I got this codes from another web and mod some . it succeed and works , but my question how should link with the others tools ?
first I would select specific sheet form combobox and select price less and write the item in textbox based on COL B then should show all of data in listbox is relating of item is writing in textbox1 based on col B and brings the price less based on COL G(UNIT PRICE) .the same thing if I select price high should bring all of data which contain price less , and if I select all should show all of data for the item whether high or less with considering it shouldn't show any thing in listbox when run the userform .
it should show data in listbox after fill the combobox ,textbox, select option ,otherwise the listbox is empty .
this is the code
thanks in advance
actually I got this codes from another web and mod some . it succeed and works , but my question how should link with the others tools ?
first I would select specific sheet form combobox and select price less and write the item in textbox based on COL B then should show all of data in listbox is relating of item is writing in textbox1 based on col B and brings the price less based on COL G(UNIT PRICE) .the same thing if I select price high should bring all of data which contain price less , and if I select all should show all of data for the item whether high or less with considering it shouldn't show any thing in listbox when run the userform .
it should show data in listbox after fill the combobox ,textbox, select option ,otherwise the listbox is empty .
this is the code
VBA Code:
Dim arr
Private Sub UserForm_Initialize()
With Sheets("sheet1")
Set rg = .Range("A2:h15")
arr = rg
End With
With listbox1
.ColumnCount = 8
.ColumnWidths = "80,120,80,80,80,80,80,80,80"
.List = arr
End With
End Sub
Private Sub textbox1_Change()
Dim rw()
For i = 1 To UBound(arr)
If LCase(arr(i, 2)) Like "*" & LCase(TextBox1.Value) & "*" Then
ReDim Preserve rw(p)
rw(p) = Application.Index(arr, i, 0)
p = p + 1
End If
Next
If p = 0 Then MsgBox "NO MATCH": Exit Sub
With listbox1
If p > 1 Then
.List = Application.Transpose(Application.Transpose(rw))
Else
.Column = Application.Transpose(rw)
End If
End With
End Sub
Sub FormatLB()
With listbox1
For i = 0 To .ListCount - 1
.List(i, 1) = Format(LB.List(i, 1), "dd/mm/yyyy")
.List(i, 2) = LB.List(i, 2)
.List(i, 3) = LB.List(i, 3)
.List(i, 4) = LB.List(i, 4)
.List(i, 5) = LB.List(i, 5)
.List(i, 6) = LB.List(i, 6)
Next
End With
End Sub
Private Sub UserForm_Activate()
Dim WS As Worksheet
For Each WS In Worksheets
ComboBox1.AddItem (WS.Name)
Next WS
End Sub