MakeArrayFromExcelColumn

From scripting
Jump to: navigation, search
Function MakeArrayFromExcelColumn(ColumnNo As Integer, TotalRows As Integer) As Variant
Dim CurArr()
ReDim CurArr(1)
CurArr(0) = ""

For MK = 2 To TotalRows
    Dim CurStr As String
    CurStr = CStr(CurCells(MK, ColumnNo).Value)
    
    Dim WCounter As Integer
    WCounter = 0
    While WCounter < UBound(CurArr) And CurStr <> CurArr(WCounter)
        WCounter = WCounter + 1
    Wend
    
    If WCounter >= UBound(CurArr) Then
        CurArr(UBound(CurArr)) = CurStr
        ReDim Preserve CurArr(UBound(CurArr) + 1)
    End If
Next MK 

MakeArrayFromExcelColumn = CurArr
End Function