Written and maintained by CASRAI Editorial Board
Last updated
You have two columns of numbers and need to know whether the difference between their means is larger than chance alone would explain. Excel can do this two ways: the T.TEST function, which returns a p-value in one cell, and the Analysis ToolPak, which returns a full table including the t statistic. The short answer: pick the design first (paired, equal variance, unequal variance), then use the matching type value in T.TEST or the matching ToolPak tool. Both are covered below, with one worked data set run through each design.
What a t-test in Excel is used for in research
A t-test compares means. In research it is most often used to compare two independent groups (treated versus control), the same subjects measured twice (before and after), or one sample against a reference value. The test assumptions, such as roughly normal data within each group, are covered in conditions for a t-test; the underlying mathematics for the independent-groups case is in the independent-samples t-test guide. This page is about the clicks and cell formulas.
Which t-test to run: paired, equal variance or unequal variance
Choose by study design, then use the matching setting. Microsoft documents the three type values of T.TEST and the three matching Analysis ToolPak tools.
| Design | T.TEST type |
Analysis ToolPak tool |
|---|---|---|
| Same subjects measured twice (paired) | 1 | t-Test: Paired Two Sample For Means |
| Two independent groups, variances assumed equal | 2 | t-Test: Two-Sample Assuming Equal Variances |
| Two independent groups, variances not assumed equal | 3 | t-Test: Two-Sample Assuming Unequal Variances |
The tails argument is separate: 1 for a one-tailed test, 2 for a two-tailed test. If you cannot justify equal variances in advance, the unequal-variance option is the one that does not rely on that assumption. See also two-tailed hypothesis testing before choosing one tail.
How to do a t-test in Excel with the T.TEST function
Syntax: =T.TEST(array1, array2, tails, type). All four arguments are required.
- Put each group in its own column (for a paired test, row 2 of column B must belong to the same subject as row 2 of column A).
- Click an empty cell and type
=T.TEST(. - Select the first range for
array1, then the second forarray2. - Enter
tails(1 or 2) andtype(1, 2 or 3) from the table above, close the bracket and press Enter.
Microsoft’s own example: with A2:A10 = 3, 4, 5, 8, 9, 1, 2, 4, 5 and B2:B10 = 6, 19, 3, 2, 14, 4, 5, 17, 1, the formula =T.TEST(A2:A10,B2:B10,2,1) (paired, two-tailed) returns 0.196016.
How to find the t-test statistic in Excel
T.TEST returns a probability (the p-value), not the t statistic. To get the t statistic use the Analysis ToolPak (next sections), which prints it as t Stat, or compute it from the formula below.
What is the t formula in Excel
Excel has no single function that returns the t statistic. The formula is built from cells. For one sample against a reference value μ0, t = (x̄ − μ0) / (s / √n), with n − 1 degrees of freedom. In Excel: =(AVERAGE(A2:A10)-H1)/(STDEV.S(A2:A10)/SQRT(COUNT(A2:A10))), where H1 holds the reference value. For a paired test, put the differences in a helper column (B minus A) and run the same formula on that column with the reference value 0.
How to run a one-sample t-test in Excel
The Analysis ToolPak offers no one-sample tool: its three t-test tools are the paired and two two-sample versions listed above. Compute t with the formula in the previous heading, then turn it into a p-value with T.DIST.2T(ABS(t), n-1) for a two-tailed result.
How to do a one-tailed t-test in Excel
Set tails to 1 in T.TEST. Microsoft notes that a two-tailed result is double the one-tailed result for the same data. In the ToolPak output, read the row labelled P(T<=t) one-tail. Decide the direction before looking at the data.
Install or access the Analysis ToolPak (Microsoft’s official instructions)
The ToolPak is an Excel add-in that must be loaded before it appears.
- Windows: File > Options > Add-Ins. In the Manage box select Excel Add-ins, then Go. Tick Analysis ToolPak and select OK. If it is not listed, use Browse and accept any install prompt.
- Mac: Tools > Excel Add-ins. Tick Analysis ToolPak and select OK; use Browse if it is not listed, then quit and restart Excel.
Data Analysis then appears on the Data tab.
Step by step: the Analysis ToolPak t-test
- Select Data > Data Analysis.
- Choose one of the three t-Test tools from the table above and select OK.
- Enter the Variable 1 Range and Variable 2 Range (tick Labels if your first row holds headings), and a Hypothesized Mean Difference, usually 0.
- Set Alpha (for example 0.05), choose an output location and select OK.
Output and how to read it
Microsoft describes the ToolPak output as including t Stat, P(T<=t) one-tail, t Critical one-tail, P(T<=t) two-tail and P Critical two-tail. Read it as follows:
- t Stat is the test statistic. Its sign shows which group mean was larger (Variable 1 minus Variable 2).
- Use the one-tail p-value only if you committed to a direction beforehand; otherwise use the two-tail p-value.
- If the p-value is smaller than your alpha, reject the null hypothesis of equal means. For more on interpretation and reporting see how to interpret t-test results.
Worked example with Microsoft’s data
Using the A and B values quoted above, the paired test gives p = 0.196016 in Excel (Microsoft’s figure). We independently computed the same data in SciPy, which gave t = −1.411 with 8 degrees of freedom for the paired test (two-tailed p = 0.196, matching Excel), t = −1.362 with 16 degrees of freedom and p = 0.192 for the equal-variance test, and p = 0.202 for the unequal-variance test. With the same numbers, the design choice moves the p-value, which is why it must be decided from the study design rather than by picking the smaller result. None of these is below 0.05.
Troubleshooting
| Symptom | Cause (per Microsoft) |
|---|---|
#N/A |
Paired test (type 1) where the two ranges contain different numbers of data points. |
#VALUE! |
tails or type is nonnumeric. |
#NUM! |
tails is a value other than 1 or 2. |
Decimal tails or type behaves unexpectedly |
Both are truncated to integers. |
T.TEST and ToolPak differ for unequal variances |
The ToolPak rounds the degrees of freedom to the nearest integer in its unequal-variance tool; T.TEST does not round, so small differences are expected. |
Free alternatives
| Tool | Function | Documented behaviour |
|---|---|---|
| R (free) | t.test() |
One- and two-sample tests; paired defaults to FALSE; var.equal defaults to FALSE, so Welch’s adjustment is used; mu sets the hypothesized mean; the result contains the t statistic, degrees of freedom and p-value. See t-test in R. |
| Python, SciPy (free) | scipy.stats.ttest_ind |
equal_var=True by default; equal_var=False runs Welch’s test; alternative accepts two-sided, less or greater; returns statistic, p-value and degrees of freedom. See SciPy stats. |
One difference worth knowing when moving between tools: R defaults to the Welch (unequal-variance) test, whereas SciPy’s ttest_ind defaults to equal variances, as does choosing type 2 in Excel.
FAQ
How do I find the t-test statistic in Excel?
Use Data > Data Analysis and one of the t-Test tools; the statistic appears as t Stat. T.TEST itself returns only the p-value.
What is the t formula in Excel?
The p-value function is =T.TEST(array1, array2, tails, type). The statistic has no dedicated function; build it from AVERAGE, STDEV.S, COUNT and SQRT as shown above.
How do I run, conduct or do a t-test on Excel?
Choose the design, then either enter T.TEST with the matching type, or enable the Analysis ToolPak and run the matching tool. Both routes are described step by step above.
How to cross test in Excel?
This is usually a typing variant of t-test. If you mean comparing two columns, use the paired or two-sample procedure above. A test of association between two categorical variables is a different test (chi-square), which this page does not cover.
Which is harder, SQL or Excel?
They are different tools for different jobs, so there is no meaningful ranking. For a t-test, Excel is enough for small tabular data; SQL is for querying databases, and the test itself would still be run in a statistics tool.
Sources
- Microsoft Support, T.TEST function: support.microsoft.com (read 2026-11-07)
- Microsoft Support, Load the Analysis ToolPak in Excel: support.microsoft.com (read 2026-11-07)
- Microsoft Support, Use the Analysis ToolPak to perform complex data analysis: support.microsoft.com (read 2026-11-07)
- R documentation, t.test: stat.ethz.ch (read 2026-11-07)
- SciPy documentation, scipy.stats.ttest_ind: docs.scipy.org (read 2026-11-07)
Related: F-test in Excel (checking the equal-variance assumption), Excel statistics functions.







