My existing VBA prompts the user to select and open two CSV files of data. What I need now is for excel to search column B in both files selected by the user (They have been set as 'SheetOld' and 'SheetNow') and, if any values are the same, mark that row in 'SheetNow' with the text "xdel" in column G.
Here is what I have thus far :
Sub OpenSingleFile()
MsgBox "Select today's data in first dialog, and past data for comparison in second dialog."
Dim FiltNow As String
Dim FiltOld As String
Dim CapNow As String
Dim CapOld As String
Dim FiltIndexNow As Integer
Dim FiltIndexOld As Integer
Dim DataNow As Variant
Dim DataOld As Variant
Dim SheetNow As Worksheet
Dim SheetOld As Worksheet
''' 1) LAUNCH TODAY'S DATA:::
FiltNow = "AudienceView Exported Report(*.csv),*.csv,"
FiltIndexNow = 1
CapNow = "Select today's data"
ChDir ("M:\Ticketing Services\OffSales with Live Orders")
With Application
DataNow = .GetOpenFilename(FiltNow, FiltIndexNow, CapNow)
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
If DataNow = False Then
MsgBox "No file was selected."
Exit Sub
End If
Workbooks.Open DataNow
Set SheetNow = ActiveSheet
''' 2) LAUNCH PAST DATA:::
FiltOld = "AudienceView Exported Report(*.csv),*.csv,"
FiltIndexOld = 1
CapOld = "Select past data for copmparison"
ChDir ("M:\Ticketing Services\OffSales with Live Orders")
With Application
DataOld = .GetOpenFilename(FiltOld, FiltIndexOld, CapOld)
ChDrive (Left(.DefaultFilePath, 1))
ChDir (.DefaultFilePath)
End With
If DataOld = False Then
MsgBox "No file was selected."
Exit Sub
End If
Workbooks.Open DataOld
Set SheetOld = ActiveSheet
''' 3) FIND/MARK DUPLICATES:::
End Sub
Thanks for any help you can offer. Essentially I'm happy for it to be on an "IF" formula basis but I don't know how to use the IF formula with the Dim command in VBA to reference the two files as they don't have fixed file names - they will always be different file names being opened.
Best,
Ollie.
Bookmarks