Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub SearchTerms()
- Dim folderPath As String
- Dim filename As String
- Dim wb As Workbook
- Dim n As Long
- Dim cell As Range
- Dim curr As Range
- Dim found As Boolean
- Dim foundTerm As Boolean
- Dim myArray As Variant
- folderPath = 'pathname goes here
- If Right(folderPath, 1) <> "" Then folderPath = folderPath + ""
- filename = Dir(folderPath & "*.xls")
- Do While filename <> ""
- Application.ScreenUpdating = False
- Application.Calculation = xlCalculationManual
- Set wb = Workbooks.Open(folderPath & filename)
- On Error GoTo 0
- For i = 1 To 10
- If Not IsEmpty(Cells(i, "D")) Then
- Exit For
- End If
- Next
- found = False
- n = Workbooks("jan17 search terms").Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Offset(1).Row
- For Each curr In Range("A" & i, "Z" & i)
- If InStr(1, curr.Value, "Protein", vbTextCompare) > 0 Or InStr(1, curr.Value, "Phosphosite", vbTextCompare) > 0 Or InStr(1, curr.Value, "Accession", vbTextCompare) > 0 Or InStr(1, curr.Value, "Uniprot", vbTextCompare) > 0 Then
- For Each cell In ActiveWorkbook.ActiveSheet.UsedRange
- If InStr(1, cell.Value, "search term", vbTextCompare) > 0 Then
- Workbooks("jan17 search terms").Sheets("Sheet1").Cells(n, 2).Value = "Yes"
- foundTerm = True
- Exit For
- End If
- Next
- Exit For
- End If
- Next
- If Not foundTerm Then Workbooks("jan17 search terms").Sheets("Sheet1").Cells(n, 2).Value = "-"
- 'prints filename on the side
- n = Workbooks("jan17 search terms").Sheets("Sheet1").UsedRange.Rows(Workbooks("jan17 search terms").Sheets("Sheet1").UsedRange.Rows.Count).Row
- Workbooks("jan17 search terms").Worksheets("Sheet1").Cells(n, 1).Value = filename
- wb.Close
- filename = Dir
- Loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement