Hello monhw,
Here is the updated macro code.
Sub GetData1()
Dim Data As Range
Dim DstRng As Range
Dim ID As Variant
Dim SrcRng As Range
Dim SrcWkb As Workbook
Application.ScreenUpdating = False
Set SrcWkb = Excel.Workbooks.Open("C:\Users\e156476\Documents\Data\System Queries\ExcelForm_data.xlsm")
Set SrcRng = SrcWkb.Worksheets("Data").Range("A1").CurrentRegion
Set DstRng = ThisWorkbook.Worksheets("Result").Range("B4").Resize(22, 1)
ID = ThisWorkbook.Worksheets("Result").Range("B1").Value
Set Data = SrcRng.Columns(1).Cells.Find(ID, , xlValues, xlWhole, xlByRows, xlNext, False)
If Not Data Is Nothing Then
DstRng.Value = Application.Transpose(Data.Offset(0, 1).Resize(1, 22))
End If
SrcWkb.Close SaveChanges:=False
Application.ScreenUpdating = True
End Sub
Bookmarks