I added a new command button to the userform, for testing. It has the code to find your item in column A:C.
It uses your same advanced filter code.
Check out the attached.
Private Sub CommandButton1_Click()
Dim ws As Worksheet: Set ws = Sheets(Me.KANTORCABANG.Value)
Dim col As Range, Lrng As Range
With ws
Set col = .Range("A:C").Find(what:=Me.KATAKUNCI, lookat:=xlPart)
If Not col Is Nothing Then
.Range("I1").Value = .Cells(1, col.Column).Value
.Range("I2").Value = Me.KATAKUNCI.Value
.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
.Range("I1:I2"), Copytorange:=.Range("K1:Q1"), Unique:=False
Set Lrng = .Range("K2:Q" & .Cells(.Rows.Count, "K").End(xlUp).Row)
Me.TABELDATA.RowSource = Lrng.ADDRESS(external:=True)
Me.HASILCARI.Caption = Me.TABELDATA.ListCount
Else
MsgBox "item not found"
End If
End With
End Sub
The code will not take into consideration if there is a chance surnames and first names are duplicate
Bookmarks