Forum Discussion

Rollercoasters4me's avatar
Rollercoasters4me
Copper Contributor
Dec 28, 2023
Solved

How to SORT/FILTER by number of words in a cell?

In Excel, is there a way to sort or filter only the cells that contain a single word in it? Thank you for your help. I'm a newbie. I have results that show how many times a single word or a phrase ...
  • Lorenzo's avatar
    Lorenzo
    Dec 28, 2023

    Rollercoasters4me 

     

    A #CALC! error with FILTER usually happens when, after filtering, there's nothing to return. To prevent that error you can amend your formula as follow:

     

     

    =FILTER(Table5,
      LEN(SUBSTITUTE(Table5[Words]," ","")) = LEN(Table5[Words]),
      ""
    )

     

     

    However, you will probably not get what you expect. Looking at your picture there seem to be a <space> at the begining of each [Words]. If it's really a space this could explain the issue. If you have space(s) at the begining and/or at the end of your [Words] you can update your formula as follow:

     

    =FILTER(Table5,
      LEN(SUBSTITUTE(Table5[Words]," ","")) = LEN(TRIM(Table5[Words])),
      ""
    )

     

     

    If this doen't fix the issue please post your actual worbook with uour > 6K rows (if not yet allowed to attach a file here you can upload & share it with OneDrive, Google Drive or the like)

     

    (Benefits of using Tables instead of Ranges)