I have the following code where i am searching for the word "study" and "protocol". But the code i use to find these takes a long time. Is there a better way? Can i reduce / combine some of the finds so it does not take as long. If this helps i expect to find these words somewhere in the first 25 rows of data.
If ws.Cells(Metric_Rownumber_Col_Study_Number, metric_col).Value <> "NA" Then
MsgBox ("time1")
Set result1 = input_wrksht.Cells.Find(What:="Study", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext)
Set result2 = input_wrksht.Cells.Find(What:="Protocol", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByColumns, SearchDirection:=xlNext)
MsgBox ("time2")
If Not result1 Is Nothing Then
rowresult = input_wrksht.Cells.Find(What:="study", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
colresult = input_wrksht.Cells.Find(What:="study", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext).Column
If (ws.Cells(Metric_Rownumber_Col_Study_Number, metric_col).Value <> colresult) Then
chkFile_error = True
MsgBox ("Check study col number in input file and Necessary_col_file.")
GoTo end_chk_inputfile
End If
ElseIf Not result2 Is Nothing Then
rowresult = input_wrksht.Cells.Find(What:="protocol", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row
colresult = input_wrksht.Cells.Find(What:="protocol", After:=[A1], LookIn:=xlValues, SearchOrder:=xlByRows, SearchDirection:=xlNext).Column
If (ws.Cells(Metric_Rownumber_Col_Study_Number, metric_col).Value <> colresult) Then
chkFile_error = True
MsgBox ("Check study col number in input file and Necessary_col_file.")
GoTo end_chk_inputfile
End If
Else: chkFile_error = True
MsgBox ("Could not find study col or protocol number in the input file. ")
GoTo end_chk_inputfile
End If
End If
Bookmarks