Yes. Excel can compare means with a t-test using the T.TEST function or the Analysis ToolPak. Choose the test that matches your data—paired, two-sample equal variance, or two-sample unequal variance—and interpret its p-value in the context of your study.
What a t-test compares
A t-test uses sample data to assess whether the difference between one or two means is consistent with a stated null hypothesis. For two independent groups, the usual null hypothesis is that their population means are equal. For paired measurements, it is that the mean of the within-pair differences is zero.
The test returns a p-value: a measure of how unusual results at least as extreme as the observed result would be if the null hypothesis and the test’s assumptions were true. A t-test does not establish that one treatment caused a change, prove that two populations are identical, or tell you whether a difference matters in practice. Those conclusions depend on the study design, the size of the difference, and the uncertainty around it.
Excel calculates the test, but it cannot decide whether the observations are independent, whether two rows belong together, or whether the result is important for your question. Those are decisions you make before selecting a test.
Choose the right type of t-test
Excel’s function and ToolPak offer three common choices. Use the design of the data—not whichever option produces the smallest p-value—to select among them.
- Paired two-sample test: Use this when each value in one group is naturally matched to a value in the other. Examples include measurements from the same people before and after an intervention, or matched pairs of subjects. The analysis is based on the differences within pairs.
- Two-sample equal-variance test: Use this for two independent groups when treating their population variances as equal is justified. This is also called the pooled t-test. Equal group sizes do not, by themselves, prove that the variances are equal.
- Two-sample unequal-variance test: Use this for independent groups when you do not have a sound reason to assume equal population variances. It is commonly called Welch’s t-test and is a sensible default for many comparisons of independent groups.
For example, comparing the same ten employees’ scores before and after training calls for a paired test. Comparing ten employees who received training with a separate group of ten who did not calls for an independent two-sample test. Treating the first example as independent would discard the matching and could give an inappropriate estimate of uncertainty.
Run a t-test with T.TEST
In current Microsoft 365 Excel for Windows, T.TEST returns a p-value directly. Its arguments are the first data array, the second data array, the number of tails, and the test type. Set tails to 2 for the usual two-sided question—whether the means differ in either direction—or to 1 only when a one-sided hypothesis was specified in advance and is appropriate for the study.
For the test type, enter 1 for paired, 2 for two-sample equal variance, or 3 for two-sample unequal variance. A two-sided Welch test is therefore type 3 with tails set to 2. The function returns the probability for the selected test; it does not return the mean difference, a confidence interval, or a plain-language conclusion.
With the first group’s observations in A2:A11 and the independent second group’s observations in B2:B11, use this formula for a two-sided Welch test:
=T.TEST(A2:A11,B2:B11,2,3)
Check that the ranges contain numeric observations and that they represent the groups you intend to compare. For paired data, the ranges must have the same number of observations and corresponding rows must refer to the same pairs. Blank cells and nonnumeric entries can affect which values are included, so inspect the data before relying on the result.
Use the Analysis ToolPak
The Analysis ToolPak provides a dialog-based alternative and produces a fuller output table, including group means, variances, the test statistic, degrees of freedom, and p-values. To enable it in Excel for Microsoft 365 on Windows, go to File > Options > Add-ins. At the bottom, set Manage to Excel Add-ins, choose Go, select Analysis ToolPak, and choose OK. Then open Data > Data Analysis and select the appropriate t-test from the list.
In the dialog, provide the input ranges, indicate whether the first row contains labels, enter the hypothesized mean difference (usually zero), and set the significance level if you want Excel to show a critical value. Select an output range or a new worksheet. The paired option expects the two input ranges to align by row; the independent options use separate group ranges.
On Excel for Mac, the add-in is managed through Tools > Excel Add-ins; select Analysis ToolPak and confirm. The Data Analysis command is then available on the Data tab in supported desktop versions. Excel for the web can calculate T.TEST in a worksheet, but the desktop ToolPak workflow may not be available there.
Worked example with a p-value
Suppose five students’ scores in one class are 8, 9, 6, 7, and 10, while a separate class has scores of 5, 6, 4, 7, and 3. The first class mean is 8 and the second is 5, so the observed difference is 3 points. Because the classes contain different students, use an independent two-sample test, not a paired test.
With the first class scores in A2:A6 and the second class scores in B2:B6, calculate the two-sided unequal-variance p-value with:
=T.TEST(A2:A6,B2:B6,2,3)
For these values, Excel returns approximately 0.0171. Each group has a sample variance of 2.5; with equal sample sizes and variances in this example, the test statistic is 3 and the Welch degrees of freedom are 8. The result is below a commonly chosen 0.05 threshold, so the data would be described as statistically significant at that threshold, assuming the test’s conditions and the analysis plan are appropriate. The small example illustrates the calculation; it is not a reason to treat a five-person group as adequate for every real study.
Interpret the result responsibly
Choose a significance level, often called alpha, before interpreting the p-value. If a valid two-sided test gives a p-value below alpha, the result is conventionally called statistically significant. If it is above alpha, you have not established a difference; that does not prove the means are equal. A study with few observations or substantial variability may fail to detect a real difference.
Statistical significance is not the same as practical importance. A tiny difference can produce a low p-value with a large sample, while a meaningful difference can remain uncertain with a small sample. Report the group means, the difference in means, the sample sizes, the test used, and the p-value. Where possible, also report a confidence interval for the difference and explain what size of change would matter in the real setting.
Be cautious about repeated testing. Trying several outcomes, subgroups, or test choices and reporting only the smallest p-value increases the chance of a misleading finding. If you have many groups rather than just two, running every pair of t-tests can also inflate false-positive risk; consider an analysis designed for multiple groups and appropriate follow-up comparisons.
Assumptions and common data problems
A t-test is not automatically suitable just because the data are in two columns. For an independent test, observations should be independent within and between groups. For a paired test, the pairs should be meaningful and independent of other pairs. The outcome should be quantitative, and extreme outliers can strongly affect means and test results.
For small samples, the distribution of the outcome—or, for paired data, the distribution of the differences—should be reasonably compatible with the t-test’s normality assumption. The method is often robust to moderate departures with larger samples, but a large sample does not fix dependence, severe outliers, biased sampling, or poor measurement. A chart of the data can reveal issues that a single p-value cannot.
- Do not pair rows merely because they occupy the same spreadsheet row. Pair only observations connected by the study design.
- Do not use the equal-variance option just because it is listed first. Use Welch’s test when equal variances are not justified.
- Check for text stored as numbers, blanks, duplicated records, and accidental inclusion of headers in the input range.
- Keep missing-data handling consistent. Do not silently remove different observations in a way that breaks genuine pairs.
These checks matter more than choosing a complicated spreadsheet technique. Excel will return a number even when the data layout or the scientific assumptions are wrong.
Frequently Asked Questions
Does Excel have a built-in t-test?
Yes. Use the worksheet function T.TEST for a p-value, or enable the Analysis ToolPak for a dialog and a broader results table.
Which Excel t-test should I use for two independent groups?
Use the two-sample unequal-variance test, also called Welch’s test, unless you have a defensible reason to assume equal population variances. In T.TEST, that is type 3.
How do I run a paired t-test in Excel?
Put the matched measurements in corresponding rows, then use T.TEST with tails set to 2 and type set to 1 for a two-sided paired test. Confirm that each row really represents a pair.
Does T.TEST return the t-statistic?
No. The function returns a p-value. The Analysis ToolPak output includes a t-statistic and other test details, which can be useful when you need to report more than the p-value.
Can Excel compare more than two means with a t-test?
A t-test compares two means at a time. For three or more groups, use an appropriate method such as analysis of variance rather than running many unadjusted pairwise t-tests.
Related
- Attendance Point System Template Excel: Build and Use
- Attendance Excel Template: Free Options and Setup
- Attendance Log Excel Template: Build One That Works
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Double Space a Paper in Word on Windows and MacTo double space a paper in Microsoft Word, select the text you want to change, then choose Home…
- How to Add a Shared Mailbox in New Outlook for WindowsTo add a shared mailbox in New Outlook for Windows, open Mail, right-click your account name in the…
- Future Out of Office in Outlook: How to Schedule ItTo schedule a future out-of-office reply in Outlook, open Automatic Replies, turn on the option to send replies…
- Excel Keyboard Shortcut to Insert Today’s DateIn Excel for Microsoft 365 on Windows, press Ctrl+; (Control plus the semicolon key) to insert today’s date…
- How to Flip the Order of Cells in Excel Without Re-typingTo flip cells in Excel, add a helper column containing 1, 2, 3, and so on, select the…
- XLOOKUP in Google Sheets From Another Sheet: A GuideYes. In Google Sheets, XLOOKUP can search a range on another tab in the same spreadsheet: if the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.