Code:
Function LastRowInOneColumn(ByRef RngOfData As Integer)
'Find the last used row in a Column: column A in this example
Dim LastRow As Long
With ActiveSheet
LastRow = .Cells(.Rows.count, "A").End(xlUp).Row
End With
RngOfData = LastRow
MsgBox LastRow
End Function
Function Array_Unique(Arr As Variant) As Variant
Dim tempArray As Variant
Dim i As Long
' start the temp array with one element and
' populate with first value
ReDim tempArray(0)
tempArray(0) = Arr(LBound(Arr))
For i = LBound(Arr) To UBound(Arr)
If Not IsInArray(tempArray, Arr(i)) And Arr(i) <> "" Then ' not in destination array
ReDim Preserve tempArray(UBound(tempArray) + 1)
tempArray(UBound(tempArray)) = Arr(i)
End If
Next i
Array_Unique = tempArray
End Function
Function IsInArray(Arr As Variant, valueToFind As Variant) As Boolean
Dim i As Long
For i = LBound(Arr) To UBound(Arr)
If StrComp(Arr(i), valueToFind) = 0 Then
IsInArray = True
Exit For
End If
Next i
End Function
Sub Testingthis()
Dim arr As Variant
Dim arrOriginal As Variant
Dim Rng As Range
'Dim arrOriginal() As Variant
Dim arrTemp() As String
Dim strPrintMsg As String 'For debugging
Dim i As Long, lCounter As Long
Dim FunctionDerivedRng As Integer
LastRowInOneColumn FunctionDerivedRng
Set Rng = Range(Cells(1, 1), Cells(FunctionDerivedRng, 1))
arrOriginal = Rng
arr = Array("January", "May", "", "April", "May")
ArrTest = Array("January", "May", "", "April", "May")
ArrTest = Array_Unique(arr)
Stop
arrOriginal = Array_Unique(arrOriginal)
' Arr = CleanUpArray(Arr)
Debug.Print "Blank"
End Sub
My Test case works where I manually enter string or numbers etc into the array but when I try to feed a range into the array thinks explode and I cant seem to make any progress
Last edited: