hello
I need helping to adapt my project . what I want when run the userform should just show highlighted data by yellow also when writing item into textbox1 based on column 4 into list box should show data based on textbox1 .
so when run userform or search item into textbox1 should just depends on higlighted data as in sheet
this is userform
the whole code
should be when run userform
when search for specific item
I need helping to adapt my project . what I want when run the userform should just show highlighted data by yellow also when writing item into textbox1 based on column 4 into list box should show data based on textbox1 .
so when run userform or search item into textbox1 should just depends on higlighted data as in sheet
البحث بالتيكست بوكس معتمدة على بيانات بالليست بوكس.xlsm | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | |||
1 | DATE | CLIENT NO | INVOICE NO | ID-CC | BB-R | TT-Y | OR-GG | QTY | PRICE | TOTAL | ||
2 | 05/01/2021 | CC2-TRB-1 | INV-TRGG-1 | IDTR-100 | FFDOOD-1 | PACK-2 | TTR | 60.00 | $120.00 | $7,200.00 | ||
3 | 06/01/2021 | CC2-TRB-1 | INV-TRGG-1 | IDTR-101 | FFDOOD-2 | PACK-3 | BBR | 10.00 | $130.00 | $1,300.00 | ||
4 | 07/01/2021 | CC2-TRB-1 | INV-TRGG-1 | IDTR-102 | FFDOOD-3 | PACK-4 | LLR | 5.00 | $100.00 | $500.00 | ||
5 | 08/01/2021 | CC2-TRB-1 | INV-TRGG-1 | IDTR-103 | FFDOOD-4 | PACK-5 | MMR | 10.00 | $289.00 | $2,890.00 | ||
6 | 09/01/2021 | CC2-TRB-2 | INV-TRGG-2 | IDTR-104 | FFDOOD-5 | PACK-6 | ASDR | 5.00 | $140.00 | $700.00 | ||
7 | 10/01/2021 | CC2-TRB-2 | INV-TRGG-2 | IDTR-100 | FFDOOD-1 | PACK-2 | TTR | 30.00 | $100.00 | $3,000.00 | ||
8 | 11/01/2021 | CC2-TRB-2 | INV-TRGG-2 | IDTR-101 | FFDOOD-2 | PACK-3 | BBR | 50.00 | $120.00 | $6,000.00 | ||
9 | 12/01/2021 | CC2-TRB-2 | INV-TRGG-2 | IDTR-107 | FFDOOD-6 | PACK-7 | FFG | 12.00 | $200.00 | $2,400.00 | ||
10 | 13/01/2021 | CC2-TRB-2 | INV-TRGG-2 | IDTR-108 | FFDOOD-7 | PACK-8 | GGF | 13.00 | $100.00 | $1,300.00 | ||
PURCHASE |
Cell Formulas | ||
---|---|---|
Range | Formula | |
J2:J10 | J2 | =H2*I2 |
this is userform
the whole code
VBA Code:
Option Explicit
Dim a As Variant
Private Sub TextBox1_Change()
Call FilterData
End Sub
Private Sub TextBox2_Change()
Call FilterData
End Sub
Private Sub TextBox3_Change()
Call FilterData
End Sub
Sub FilterData()
Dim i As Long, ii As Long, n As Long
Me.ListBox1.List = a
If Me.TextBox1 = "" Then Exit Sub
With Me.ListBox1
.Clear
For i = 0 To UBound(a, 1)
If UCase$(a(i, 3)) Like UCase$(Me.TextBox1) & "*" Then
.AddItem
.List(n, 0) = n + 1
For ii = 1 To UBound(a, 2)
.List(n, ii) = a(i, ii)
Next
n = n + 1
End If
Next
End With
End Sub
Private Sub UserForm_Activate()
End Sub
Private Sub UserForm_Initialize()
Dim lindex&
Dim rngDB As Range, rng As Range
Dim i, myFormat(1) As String
Dim sWidth As String
Dim vR() As Variant
Dim n As Integer
Dim myMax As Single
Set rngDB = Range("A2:J20")
For Each rng In rngDB
n = n + 1
ReDim Preserve vR(1 To n)
vR(n) = rng.EntireColumn.Width
Next rng
myMax = WorksheetFunction.Max(vR)
For i = 1 To n
vR(i) = myMax
Next i
With Sheets("purchase").Cells(1).CurrentRegion
myFormat(0) = .Cells(2, 8).NumberFormatLocal
myFormat(1) = .Cells(2, 9).NumberFormatLocal
Set rng = .Offset(1).Resize(.Rows.Count - 1)
a = .Cells(1).CurrentRegion.Value
End With
sWidth = Join(vR, ";")
Debug.Print sWidth
With ListBox1
.ColumnCount = 10
.ColumnWidths = sWidth '<~~ 63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63;63
.List = rng.Value
.BorderStyle = fmBorderStyleSingle
For lindex = 0 To .ListCount - 1
'.List(lindex, 0) = (Format((.List(lindex, 0)), "dd/mm/yyyy")) ' BL = dates
.List(lindex, 0) = lindex + 1
.List(lindex, 7) = Format$(.List(lindex, 7), myFormat(0))
.List(lindex, 8) = Format$(.List(lindex, 8), myFormat(1))
.List(lindex, 9) = Format$(.List(lindex, 9), myFormat(1))
Next
a = .List
'<--- this line
End With
End Sub
when search for specific item