Examine workbook cell for existing Primary Key

CutAndPaste

Registered User.
Local time
Today, 00:30
Joined
Jul 16, 2001
Messages
60
I want to examine a specific cell in each workbook in a folder prior to import to look for a unique ID in a table. If it exists, then I want to send a message to the user that the data already exists, not import that workbook and go on to the next workbook .

This is the code I used to iterate through all the workbooks in a folder to import all of the data (prior to wanting to exclude pre-existing data). I think I can use it again, but the method of checking and allowing/rejecting each Workbook eludes me!


=====Start Code ========
'Loops through all files in folder

Private Sub Command102_Click()

Dim ImportFileName As String
Dim ImportFolder As String

ImportFolder = Me.ImportFolder ' Field on form
ImportFileName = Dir(ImportFolder & "\*.xls") 'Alter File Extension here if required

Do

'Code to do stuff with each workbook here
'
'Get the next file match
ImportFileName = Dir()
Loop While ImportFileName > ""
End Sub
=====End Code====

thanks!
 

Users who are viewing this thread

Back
Top Bottom