search data not only based on first word in search engine VBA

Robyrubyjane

New Member
Joined
Feb 8, 2023
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Hello, im looking for help. so i was made a search engine with VBA
For example i would like to search Surname "Ace bisa", and I write "Ace" on kata kunci, and the result will shown.

Screenshot 2023-05-16 152505.png

but when I write "bisa" the data wasn't found.
Screenshot 2023-05-16 152739.png

can you guys help me to fix this?

Thanks in advance

*I want to upload the file but i dont know how to upload it

1684228128804.png

here is the code

VBA Code:
Private Sub CARIDATA_Click()
On Error GoTo SALAH
If Me.KANTORCABANG.Value = "" Then
Call MsgBox("Silahkan Pilih Kantor Cabang terlebih dahulu", vbInformation, "Cari Data")
End If

If Me.KANTORCABANG.Value = "Surabaya" Then
Set CariSurabaya = Sheet1
CariSurabaya.Range("I1").Value = Me.BERDASARKAN.Value
CariSurabaya.Range("I2").Value = Me.KATAKUNCI.Value
CariSurabaya.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Sheet1.Range("I1:I2"), Copytorange:=Sheet1.Range("K1:Q1"), Unique:=False
Me.TABELDATA.RowSource = Sheet1.Range("HasilSurabaya").ADDRESS(external:=True)
Me.HASILCARI.Caption = Me.TABELDATA.ListCount
End If

If Me.KANTORCABANG.Value = "Jakarta" Then
Set CariSurabaya = Sheet2
CariSurabaya.Range("I1").Value = Me.BERDASARKAN.Value
CariSurabaya.Range("I2").Value = Me.KATAKUNCI.Value
CariSurabaya.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Sheet2.Range("I1:I2"), Copytorange:=Sheet2.Range("K1:Q1"), Unique:=False
Me.TABELDATA.RowSource = Sheet2.Range("HASILJAKARTA").ADDRESS(external:=True)
Me.HASILCARI.Caption = Me.TABELDATA.ListCount
End If

If Me.KANTORCABANG.Value = "Semarang" Then
Set CariSurabaya = Sheet3
CariSurabaya.Range("I1").Value = Me.BERDASARKAN.Value
CariSurabaya.Range("I2").Value = Me.KATAKUNCI.Value
CariSurabaya.Range("A1").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, CriteriaRange:= _
Sheet3.Range("I1:I2"), Copytorange:=Sheet3.Range("K1:Q1"), Unique:=False
Me.TABELDATA.RowSource = Sheet3.Range("HASILSEMARANG").ADDRESS(external:=True)
Me.HASILCARI.Caption = Me.TABELDATA.ListCount
End If
Exit Sub
SALAH:
Call MsgBox("Maaf data yang dicari tidak ditemukan", vbInformation, "Cari Data")
End Sub

Private Sub KANTORCABANG_Change()
If Me.KANTORCABANG.Value = "Surabaya" Then
Me.TABELDATA.RowSource = Sheet1.Range("TABELSURABAYA").ADDRESS(external:=True)
End If

If Me.KANTORCABANG.Value = "Jakarta" Then
Me.TABELDATA.RowSource = Sheet2.Range("TABELJAKARTA").ADDRESS(external:=True)
End If

If Me.KANTORCABANG.Value = "Semarang" Then
Me.TABELDATA.RowSource = Sheet3.Range("TABELSEMARANG").ADDRESS(external:=True)
End If

End Sub

Private Sub RESET_Click()
Me.BERDASARKAN.Value = ""
Me.KANTORCABANG.Value = ""
Me.KATAKUNCI.Value = ""
Me.TABELDATA.RowSource = ""
Me.HASILCARI.Caption = ""
End Sub

Private Sub TABELDATA_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
With FORMKARYAWAN
.ID.Value = Me.TABELDATA.Value
.SURNAME.Value = Me.TABELDATA.Column(1)
.FIRSTNAME.Value = Me.TABELDATA.Column(2)
.ADDRESS.Value = Me.TABELDATA.Column(3)
.PHONE.Value = Me.TABELDATA.Column(4)
.MOBILE.Value = Me.TABELDATA.Column(5)
.EMAIL.Value = Me.TABELDATA.Column(6)
End With
FORMKARYAWAN.Show
End Sub
Private Sub UserForm_Initialize()
With KANTORCABANG
.AddItem "Surabaya"
.AddItem "Jakarta"
.AddItem "Semarang"
End With

With BERDASARKAN
.AddItem "ID"
.AddItem "Surname"
.AddItem "First Name"
End With

End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
A reminder:

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at:

There is no need to repeat the link(s) provided above but if you have posted the question at other places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
sorry
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top