Difference between pages "MEL TEST1" and "MakeArrayFromExcelColumn"
From scripting
(Difference between pages)
(Created page with "{{:Category:In-House MEL}} {{:Category:MEL}}") |
(Created page with " Function MakeArrayFromExcelColumn(ColumnNo As Integer, TotalRows As Integer) As Variant Dim CurArr() ReDim CurArr(1) CurArr(0) = "" For MK = 2 To TotalRows Dim Cur...") |
||
Line 1: | Line 1: | ||
− | + | 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 | ||
− | + | ||
+ | [[Category:CATIA DP VB]] |
Latest revision as of 07:20, 22 April 2017
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