Excel Exact Word Matching

前端 未结 5 900
遥遥无期
遥遥无期 2021-01-23 00:38

Let\'s say I have \"Vegas is great\" in cell A1. I want to write a formula that looks for the exact word, \"gas\" in cells. Vegas ≠ gas, but the only search formula I\'m finding

5条回答
  •  死守一世寂寞
    2021-01-23 01:22

    I believe to correctly cover cases you have to pad spaces before and after the term "gas" and the search term. This will ensure that gas will be found at the beginning or end of a cell, and also prevent it from being found in the middle of any words. Your post does not indicate whether punctuation can exist in the file, but to accomodate punctuation padding spaces around the search will not work correctly, you would have to include the case of " gas. " " gas! " etc to allow for any punctuation specifically. If you are worried about catching values like "gas.cost" or similar you can use the same padding around the punctuation search.

    =Or(ISNUMBER(SEARCH(" gas ", " "&A1&" ")),ISNUMBER(SEARCH(" gas. ", " "&A1&" ")))

    Is a basic search that should return the word gas by itself, or "gas." By padding a space after "gas." in the search it will find it as the final word in a sentence, or at the end of a cell.

    Edit: Dropped a parentheses.

提交回复
热议问题