excel - Range.Find fails on ranges that are both hidden AND part of a filter -
i'm experiencing peculiar problem in excel 2003 range.find method fails when searching value in cell both hidden , part of filtered range.
to clear, method call in question:
cells.find(searchstring, lookin:=xlformulas, lookat:=xlwhole)
- if cell containing searchstring merely hidden, range.find works.
- if cell containing searchstring merely part of filtered range (but not hidden), range.find works.
- if cell containing searchstring both hidden (by filter or otherwise), , part of filtered range, range.find fails.
many sources on various excel sites , forums claim specifying "lookin:=xlformulas" force range.find search within hidden cells. though nonsensical, seems true if searchstring in cell merely hidden. if cell both hidden , part of filtered range, fails.
note doesn't matter if cell being hidden by filter. example, can search heading of filtered range (which never hidden filter itself), if heading happens in column you've hidden, range.find fail.
is there excel method reliably search cells without regard whether or not happen hidden and/or part of filter?
you can cook own find function:
private function findanywhere(target range, search variant) range dim values() variant dim row long dim col long values = target.value row = lbound(values, 1) ubound(values, 1) col = lbound(values, 2) ubound(values, 2) if values(row, col) = search set findanywhere = target.cells(row, col) exit function end if next col next row end function
the caveat if you're using (or intending use) findprevious or findnext you'll have track areas of range you've searched.