Graag wil ik met 1 macro button 2 bestanden inlezen op verschillende positie. mij is het niet gelukt om de onderstaande door te lussen. Heeft iemand een optie hoe je dit beste kan doen?
Code:
Private Sub CommandButton1_Click()
c00 = ThisWorkbook.Path & "\Productie ok.xls"
With GetObject(c00)
ar = .Sheets(1).Cells(1).CurrentRegion
.Close 0
End With
y = Application.Transpose(Application.Index(ar, 0, 1))
ar1 = Sheets("ok").Cells(3, 1).CurrentRegion.Resize(, 19)
For j = 2 To UBound(ar1)
x = Application.Match(ar1(j, 1), y, 0)
If IsNumeric(x) Then
For jj = 2 To 19
ar1(j, jj) = ar(x, jj)
Next jj
End If
Next j
Sheets("ok").Cells(3, 1).CurrentRegion.Resize(, 19) = ar1
End With
c00 = ThisWorkbook.Path & "\Productie ok1.xls"
With GetObject(c00)
ar = .Sheets(1).Cells(1).CurrentRegion
.Close 0
End With
y = Application.Transpose(Application.Index(ar, 0, 1))
ar1 = Sheets("ok").Cells(34, 1).CurrentRegion.Resize(, 19)
For j = 2 To UBound(ar1)
x = Application.Match(ar1(j, 1), y, 0)
If IsNumeric(x) Then
For jj = 2 To 19
ar1(j, jj) = ar(x, jj)
Next jj
End If
Next j
Sheets("ok").Cells(34, 1).CurrentRegion.Resize(, 19) = ar1
End If
End Sub
Laatst bewerkt door een moderator: