Find method of excel vba in activated workbook -
all hints find concerning search functionality in vba-excel refers same workbook. however, after activating workbook, in snippet of code
adifferentworkbook.activate set found = cells.find(what:=lookedfor.text, lookin:=xlvalues, lookat:=xlwhole) the result found nothing = true although lookedfor.text present in workbook. know if there special rules after switching different workbook?
thank deved
you need select worksheet within workbook:
adifferentworkbook.activate 'optional adifferentworkbook.sheets(1).select set found = cells.find(what:=lookedfor.text, lookin:=xlvalues, lookat:=xlwhole) then select next sheet , on.
slightly cuter code is
dim ws excel.worksheet each ws in adifferentworkbook.worksheets set found = ws.cells.find(what:=lookedfor.text, lookin:=xlvalues, lookat:=xlwhole) next ws as avoids selection
Comments
Post a Comment