By using vba.booksticle.com you agree to our cookie policy, We and our partners operate globally and use cookies, for multiple purposes

948 Steps to 6 Figures by Learning Excel-VBA and Other Skills



Step 484 - LoadArray(sWBK, sSheet, header)


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

   Table of Contents | Send us your feedback | © 2025 All Rights Reserved | Edit