I am totally lost on this looping stuff. I am new to this, and am still learning so please bear with me. How Do I tell the code that if the dqNumber is not found, move on to the next file in the folder?
1 Code:
for each file in folder1.files if (Left(file.Name,Len(file.Name) - InStr(file.Name,".ci"))) = "DQ" then cidFileName = file.Name dqNumber = replace(file.name,".ci","") ForReading1 = 1 'Create the file system object Set fso = CreateObject("Scripting.FileSystemObject") 'Initialize a few items strSource = "F:\Am\EXCEL.CSV" 'Open the source file to read it Set ts = fso.OpenTextFile(strSource,ForReading1) 'Read the file line by line Do while not ts.AtEndOfStream strLine = ts.ReadLine 'Remove the quotes from the string strLine = Replace(strLine, Chr(34), "") 'Split the line on the comma into an array strValues = Split(strLine, ",") 'Check if the dq number matches For i = 15 to 27 If strValues(i) = dqNumber Then 'Get the other values you need soNumber = strValues(0) setNumber = strValues(2) sideNumber = strValues(4) 'Set flag that say the value was found blnFound = True 'Exit the loop Exit Do End If Next Loop 'Close the file ts.Close msgbox(soNumber&" "&setNumber&" "&sideNumber) End If Next




Reply With Quote