graag wou ik verticaal zoeken op externe bestand. kan iemand mij hierbij helpen.
kolom A in bestand ''test macro vert. zoeken'' is zoek criteria en de achterste gegevens zou die overnemen en overschrijven vanuit bestand testmacro2. na klik op de button in bestand ''test macro vert. zoeken''.
tnxx
kolom A in bestand ''test macro vert. zoeken'' is zoek criteria en de achterste gegevens zou die overnemen en overschrijven vanuit bestand testmacro2. na klik op de button in bestand ''test macro vert. zoeken''.
tnxx
Code:
Sub CommandButton1_Click()
On Error Resume Next
With Sheets("Hoofd")
.Range("B1:B" & .Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
For Each cl In .Range("A1:A" & .Cells(Rows.Count, 1).End(xlUp).Row)
For i = 2 To Sheets.Count
If cl.Offset(, 1) <> "" Then Exit For
cl.Offset(, 1) = Sheets(i).Columns(1) _
.Find(cl, , xlValues, xlWhole, xlByRows, xlNext, False).Offset(, 1).Value
Next
If Not BookOpen("testmacro2.xls") Then Workbooks.Open ThisWorkbook.Path & "\" & "testmacro2.xls"
ThisWorkbook.Activate
If cl.Offset(, 1) = "" Then
cl.Offset(, 1) = Workbooks("testmacro2.xls").Sheets("gegevensmedewerkers").Columns(1) _
.Find(cl, , xlValues, xlWhole, xlByRows, xlNext, False).Offset(, 1).Value
End If
Next
End With
Workbooks("testmacro2.xls").Close , False
End Sub
Function BookOpen(wbName As String) As Boolean
Dim wb As Workbook
On Error Resume Next
Set wb = Workbooks(wbName)
BookOpen = Not (Err.Number > 0)
End Function