Function LoadArray(sWBK, sSheet, header) Dim a() Dim c As Long, r As Long sCur = ActiveSheet.Name sCurWBK = ActiveWorkbook.Name Windows(sWBK).Activate Sheets(sSheet).Visible = True c = FindDataCol(header, 1) If c = 0 Then LoadArray = "Error: can't find field '" & header & "' on Lookup sheet" Exit Function End if r = FindLastRow(c) On Error Resume Next Redim Preserve a(r-2) ' -1 for header and -1 for 0 offset For i = 2 To r a(i - 2) = Cells(i, c) Next Windows(sCurWBK).Activate ShowSheet sCur LoadArray = a End Function |