Hi,
I am trying to right a sub that opens a csv file adds to an array, then the data of the first column of the array to find unique values compared to the database in a worksheet. Values that come back TRUE will have the rest of the data in the array row added to the bottom of the dataset in the worksheet.
I am struggling with the final bit, the code is searching all values and i cannot see how to extract the rows I wish.
Any thoughts would be great!
Note: GetFile() is a Function
y row added to the bottom of the data base.
I am trying to right a sub that opens a csv file adds to an array, then the data of the first column of the array to find unique values compared to the database in a worksheet. Values that come back TRUE will have the rest of the data in the array row added to the bottom of the dataset in the worksheet.
I am struggling with the final bit, the code is searching all values and i cannot see how to extract the rows I wish.
Any thoughts would be great!
Note: GetFile() is a Function
VBA Code:
Option Explicit
Sub LoadToArray()
Application.ScreenUpdating = False
Dim file As String: file = GetFile()
Dim wbCSV As Workbook
Dim Data As Variant
Dim rg As Range
Set wbCSV = Workbooks.Open(filename:=file, ReadOnly:=True)
Set rg = wbCSV.Worksheets(1).Range("A1").CurrentRegion
Data = rg.Value
wbCSV.Close SaveChanges:=False
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim ws As Worksheet
Dim activeSheetData As Range
Dim cellValue As Variant
Dim uniqueValues As Collection
Dim lastRow As Long
Dim isUnique As Boolean
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Set ws = ActiveSheet
Set activeSheetData = ActiveSheet.Range("A1:A" & ActiveSheet.Cells(Rows.Count, 1).End(xlUp).row)
Set uniqueValues = New Collection
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).row + 1
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For Each cellValue In Data
If isUnique Then
ws.Rows(lastRow) = cellValue
Else
End If
Next cellValue
End Sub