Option Explicit
Sub uniquearray()
Dim arrdata() As String
Dim workingrange, cell As Range
Dim length As Integer
length = 0
Sheets("conditionalformattingvba").Select
Set workingrange = Range("I2").CurrentRegion
For Each cell In workingrange
length = length + 1
ReDim Preserve arrdata(length) As String
arrdata(length) = cell.Value
Next cell
'For length = 1 To UBound(arrdata)
'Debug.Print (arrdata(length))
'Next length
'MsgBox (arrdata(0))
Dim uniquearray() As String
Dim i As Integer
ReDim uniquearray(1) As String
For length = 1 To UBound(arrdata)
For i = 1 To UBound(uniquearray)
'Debug.Print tempstr1 & " and " & tempstr2
If arrdata(length) = uniquearray(i) Then
Exit For
End If
Next i
If i > UBound(uniquearray) Then
uniquearray(UBound(uniquearray)) = arrdata(length)
ReDim Preserve uniquearray(UBound(uniquearray) + 1) As String
End If
Next length
ReDim Preserve uniquearray(UBound(uniquearray) - 1) As String
For length = 1 To UBound(uniquearray)
Debug.Print (uniquearray(length))
Next length
End Sub
Sub uniquearray()
Dim arrdata() As String
Dim workingrange, cell As Range
Dim length As Integer
length = 0
Sheets("conditionalformattingvba").Select
Set workingrange = Range("I2").CurrentRegion
For Each cell In workingrange
length = length + 1
ReDim Preserve arrdata(length) As String
arrdata(length) = cell.Value
Next cell
'For length = 1 To UBound(arrdata)
'Debug.Print (arrdata(length))
'Next length
'MsgBox (arrdata(0))
Dim uniquearray() As String
Dim i As Integer
ReDim uniquearray(1) As String
For length = 1 To UBound(arrdata)
For i = 1 To UBound(uniquearray)
'Debug.Print tempstr1 & " and " & tempstr2
If arrdata(length) = uniquearray(i) Then
Exit For
End If
Next i
If i > UBound(uniquearray) Then
uniquearray(UBound(uniquearray)) = arrdata(length)
ReDim Preserve uniquearray(UBound(uniquearray) + 1) As String
End If
Next length
ReDim Preserve uniquearray(UBound(uniquearray) - 1) As String
For length = 1 To UBound(uniquearray)
Debug.Print (uniquearray(length))
Next length
End Sub
No comments:
Post a Comment