I have one last question I can't get out of, maybe someone is kind enough to help me one more time.
With the help of VLOOKUP I search for my data in another workbook, when I start searching, the "database" file is opened for a few secconds and closed immediately.
Is there a possibility in VBA that the file database can be opened in the background or can be read out unopened and the data is written to my textboxes?
Private Sub CmdFind_Click()
Dim Search As Variant
Dim book1 As Workbook
Dim extwbk As Workbook
Dim x As Range
Set book1 = ThisWorkbook
Set extwbk = Workbooks.Open("C:\Users\Desktop\excel\database.xlsm")
Set x = extwbk.Worksheets("data").Range("A7:x10000")
Search = txtfind.Value
If IsNumeric(Search) Then Search = Val(Search)
If IsError(Application.Match(Search, x.Columns(1), 0)) Then
MsgBox "wrong number", vbCritical, Search
Exit Sub
End If
txtname.Text = Application.WorksheetFunction.VLookup(Search, x, 18, False)
Txtstreet.Text = Application.WorksheetFunction.VLookup(Search, x, 2, False)
txtnumber.Text = Application.WorksheetFunction.VLookup(Search, x, 3, False)
txtpostcode.Text = Application.WorksheetFunction.VLookup(Search, x, 4, False)
Txtprovince.Text = Application.WorksheetFunction.VLookup(Search, x, 5, False)
txtcity.Text = Application.WorksheetFunction.VLookup(Search, x, 6, False)
txtarea.Text = Application.WorksheetFunction.VLookup(Search, x, 7, False)
Txtlastname.Text = Application.WorksheetFunction.VLookup(Search, x, 8, False)
Txtremark.Text = Application.WorksheetFunction.VLookup(Search, x, 9, False)
txtopmerking.Text = Application.WorksheetFunction.VLookup(Search, x, 10, False)
txtFoto.Text = Application.WorksheetFunction.VLookup(Search, x, 11, False)
txtcount.Text = Application.WorksheetFunction.VLookup(Search, x, 12, False)
extwbk.Close savechanges:=False
End Sub