excel - Remove character only during search? -
i have excel file faq lots of q&a. on first worksheet there search function. enter word(s) want search , press enter. function looks these word(s) in entire workbook. able proper search have remove full stop, comma, exclamation , question marks.
i use replace
this, didn't think of consequences. characters remove permanently text makes little hard read , ugly at.
so question is, how can remove these characters during search? have copy each text new cell , search there, or there way?
this part of function remove characters , final search.
function findwords(celltosearch range, nofwords integer, mywords string) long dim counter long dim word, element dim arr, wordsarr celltosearch = replace(celltosearch, chr(33), "") celltosearch = replace(celltosearch, chr(44), "") celltosearch = replace(celltosearch, chr(46), "") celltosearch = replace(celltosearch, chr(63), "") wordsarr = split(mywords) arr = split(celltosearch) if ubound(arr) > 0 each word in wordsarr each element in arr if lcase(word) = lcase(element) counter = counter + 1 next next else ' cell search empty counter = 0 end if if counter = nofwords findwords = 1 else findwords = 0 end if end function
you use variable:
function findwords(celltosearch range, nofwords integer, mywords string) long dim counter long dim word, element dim arr, wordsarr dim sfindword string sfindword = celltosearch.value sfindword = replace(sfindword , chr(33), "") sfindword = replace(sfindword , chr(44), "") sfindword = replace(sfindword , chr(46), "") sfindword = replace(sfindword , chr(63), "") wordsarr = split(mywords) arr = split(sfindword) if ubound(arr) > 0 each word in wordsarr each element in arr if lcase(word) = lcase(element) counter = counter + 1 next next else ' cell search empty counter = 0 end if if counter = nofwords findwords = 1 else findwords = 0 end if end function
Comments
Post a Comment