Skip to main content
v2026.11,858 entries · CC-BY 4.0

How to Do a t-Test in Excel (T.TEST Function and Analysis ToolPak)

Run a t-test in Excel with T.TEST or the Analysis ToolPak: which type to choose, how to get the t statistic, read the output and fix #N/A errors.

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.

  1. 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).
  2. Click an empty cell and type =T.TEST(.
  3. Select the first range for array1, then the second for array2.
  4. Enter tails (1 or 2) and type (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

  1. Select Data > Data Analysis.
  2. Choose one of the three t-Test tools from the table above and select OK.
  3. Enter the Variable 1 Range and Variable 2 Range (tick Labels if your first row holds headings), and a Hypothesized Mean Difference, usually 0.
  4. 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

Related: F-test in Excel (checking the equal-variance assumption), Excel statistics functions.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about How to Do a t-Test in Excel (T.TEST Function and Analysis ToolPak)

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →