vba - Searching for 2 different strings in the same row -
i need find 2 strings in spreadsheet.
example omit: if both of strings in different rows
example accept: if both of strings in same row , provide hyperlink combination of strings in in column (h)
here code snippet:
'searching first string------------------------------------------- str1 = application.inputbox(prompt:="search value 1:", title:="search workbooks in folder", type:=2) if str1 = vbnullstring exit sub 'searching second string------------------------------------------- str2 = application.inputbox(prompt:="search value 2:", title:="search workbooks in folder", type:=2) if str2 = vbnullstring exit sub 'code accesing spreadsheet... each sht in activeworkbook.worksheets set c = sht.cells.find(str1, lookin:=xlvalues, lookat:=xlwhole, searchorder:=xlbyrows, searchdirection:=xlnext) set e = sht.cells.find(str2, lookin:=xlvalues, lookat:=xlwhole, searchorder:=xlbyrows, searchdirection:=xlnext) set k = sht.cells.find(str1, lookin:=xlvalues, lookat:=xlwhole, searchorder:=xlbyrows, searchdirection:=xlnext) set f = sht.cells.find(str2, lookin:=xlvalues, lookat:=xlwhole, searchorder:=xlbyrows, searchdirection:=xlnext) if not c nothing firstaddress = c.address 'used loop through worksheet secondaddress = e.address 'used loop through worksheet lrow = ws.range("a" & rows.count).end(xlup).row lrow2 = ws.range("a" & rows.count).end(xlup).row ws.range("a1").offset(lrow, 0).value = folderpath ws.range("b1").offset(lrow, 0).value = value ws.range("c1").offset(lrow, 0).value = sht.name 'this code provides link 1-st string in ws.range("d1").offset(lrow, 0).value = c.address ws.hyperlinks.add anchor:=ws.range("e1").offset(lrow, 0), address:=folderpath & value, subaddress:=sht.name & "!" & c.address, texttodisplay:="link value 1", screentip:="str 1" set c = sht.cells.findnext(c) loop while not c nothing , c.address <> firstaddress next sht
Comments
Post a Comment