Guides

How to do sentiment analysis in Excel and Google Sheets

Sentiment analysis means labelling each piece of text by the feeling behind it: usually positive, neutral or negative, sometimes a score from 1 to 5. It's how you get from a column of 2,000 reviews or survey comments to a sentence like "complaints doubled after the price change".

This guide shows three ways to do it in Excel or Google Sheets, and, just as important, how to check whether the results are any good.

Prepare the data

Method 1: a word-list formula

The classic approach: count positive words and negative words in each comment, and label it by whichever side wins.

  1. On a separate sheet, list positive words in one column (great, love, excellent, friendly, recommend…) and negative words in another (terrible, rude, broken, slow, refund…). Use lowercase.
  2. Name the two ranges: select each list and type PosWords and NegWords into the Name Box (or use Formulas → Define Name; in Sheets, Data → Named ranges). Make the ranges cover exactly the words, with no blank cells.
  3. With the comment in A2, use:
=LET(t, " " & LOWER(A2) & " ",
  p, SUMPRODUCT(--ISNUMBER(SEARCH(" " & PosWords & " ", t))),
  n, SUMPRODUCT(--ISNUMBER(SEARCH(" " & NegWords & " ", t))),
  IF(p > n, "Positive", IF(n > p, "Negative", "Neutral")))

The spaces around each word stop bad from matching inside badge. LET works in Excel 365, Excel 2021 and Google Sheets. On older Excel, write it without LET:

=IF(SUMPRODUCT(--ISNUMBER(SEARCH(" "&PosWords&" ", " "&LOWER(A2)&" ")))
  > SUMPRODUCT(--ISNUMBER(SEARCH(" "&NegWords&" ", " "&LOWER(A2)&" "))), "Positive",
  IF(SUMPRODUCT(--ISNUMBER(SEARCH(" "&NegWords&" ", " "&LOWER(A2)&" ")))
  > SUMPRODUCT(--ISNUMBER(SEARCH(" "&PosWords&" ", " "&LOWER(A2)&" "))), "Negative", "Neutral"))

Where word lists go wrong

It's free and transparent, and good enough to spot big shifts in a large volume of comments. For row-by-row accuracy, it's usually the weakest of the three.

Method 2: AI functions built into your spreadsheet

At the time of writing, Excel (with a Microsoft 365 Copilot license) and Google Sheets (on Workspace plans that include Gemini) both offer AI functions you can call from a cell with an instruction like "classify this review as positive, neutral or negative". Check whether your plan includes them.

Method 3: a dedicated classification tool

With SheetSorter you upload the file, pick the comment column and use the ready-made Positive / Neutral / Negative labels (or define your own, or a 1–5 scale). Every row comes back with one of your exact labels, a confidence score and a "needs review" flag.

In our tests on public review data, it told positive from negative reviews apart correctly about 98% of the time, and its 1–5 ratings were within one star of the reviewer's actual rating 97% of the time. Exact five-star matches were lower, around 68%, which is normal: people don't agree on the difference between a 3 and a 4 either.

Check the accuracy, whatever you use

Every method makes mistakes; the question is how many. Ten minutes of checking tells you:

  1. Add a helper column with =RAND(), sort by it, and take the first 50 rows. That's a random sample.
  2. Label those 50 yourself in a new column, without looking at the method's answer.
  3. With your labels in C2:C51 and the method's in B2:B51, the share that match is:
=SUMPRODUCT(--(B2:B51 = C2:C51)) / ROWS(B2:B51)

Above about 85% on three labels is good. If it's lower, look at the rows that disagree: they usually point to a label that needs a clearer definition.

Summarize the results

Count each label with COUNTIF, and divide by the total for a share:

=COUNTIF(B:B, "Negative") / COUNTA(B2:B5000)

For trends, a PivotTable with the review date grouped by month in Rows, Sentiment in Columns and a count in Values shows how the mix changes over time. A stacked column chart of that table makes it easy to share.

Finally, read some of the negative comments themselves. The percentage tells you how many people are unhappy; the comments tell you why.

Want to skip the formulas? Find out which reviews and comments are positive, neutral or negative, for every row of your spreadsheet.

Sentiment analysis in Excel with SheetSorter

More guides