Mcaa51
11-06-2010, 10:15 AM
In order to avoid writing data to the worksheet one cell at a time using a loop I am trying to use the below code. This is not working correctly however, and is writing the first value in the array to the entire range on the worksheet. What am I Doing wrong? Thanks.
Sub GetUnique(wksDataSource As Worksheet, wksDataDest As Worksheet)
Dim saCpty As Variant
Dim saTempArray() As String
Dim iLoopArray As Integer
Dim rngDest As Range
saCpty = UniqueItemList(Range("CNPTY"), True)
ReDim saTempArray(1 To UBound(saCpty))
Set rngDest = wksDataDest.Range(Cells(1, 1), Cells(UBound(saCpty), 1))
For iLoopArray = 1 To UBound(saCpty)
saTempArray(iLoopArray) = saCpty(iLoopArray)
Next iLoopArray
rngDest.Value = saCpty
End Sub
Sub GetUnique(wksDataSource As Worksheet, wksDataDest As Worksheet)
Dim saCpty As Variant
Dim saTempArray() As String
Dim iLoopArray As Integer
Dim rngDest As Range
saCpty = UniqueItemList(Range("CNPTY"), True)
ReDim saTempArray(1 To UBound(saCpty))
Set rngDest = wksDataDest.Range(Cells(1, 1), Cells(UBound(saCpty), 1))
For iLoopArray = 1 To UBound(saCpty)
saTempArray(iLoopArray) = saCpty(iLoopArray)
Next iLoopArray
rngDest.Value = saCpty
End Sub