Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Correlation Coefficient Formula in Excel: How to Use It

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Excel has three functions for the correlation coefficient, and CORREL is the one you want most of the time. Type =CORREL(array1, array2), point each argument at a range of paired numbers, and press Enter. You get a value between -1 and 1: near 1 means the two variables move up together, near -1 means one rises as the other falls, and near 0 means little or no straight-line relationship. Pearson's r is the default, so CORREL gives you exactly the r you would get from the textbook formula by hand.

The hand formula is worth knowing for context, because it explains why order and pairing matter. Pearson's r is the covariance of the two variables divided by the product of their standard deviations: r = Σ[(x − x̄)(y − ȳ)] / √[Σ(x − x̄)² × Σ(y − ȳ)²]. Excel does all of that arithmetic for you, but if the two ranges are not the same length, or the rows are not paired correctly, the answer is meaningless even though Excel may still return a number. Menu labels and function names can differ slightly between Excel versions and platforms, so if a name does not match what you see, type the function and let Excel's autocomplete confirm it.

What You'll Need

  • Excel on Windows, Mac, or Excel for the web. These steps work in all three.
  • Two columns of numbers, each row holding one matched pair of observations (for example, hours of sunlight in one column and plant height in the other).
  • At least three pairs; realistically, dozens of pairs before the result means much.
  • Column headers outside the selected ranges, so labels are not read as data or text.

Step-by-Step

  1. Lay out the data with the two variables in separate columns, one pair per row. Put the x variable in column A and the y variable in column B, starting at row 2 so row 1 can hold headers. This paired layout is not optional: CORREL compares the first value of one range with the first value of the other, then the second with the second, and so on. Sorting one column without the other breaks the pairing.
  2. Check for blanks and text. Select the data columns and glance at the status bar; it shows a count of numeric cells. If either column is shorter or contains a blank, CORREL returns #N/A. Empty cells or text values inside a range are ignored for that pair, which can quietly shrink your sample, so clean them out first.
  3. Click an empty cell away from the data, say D2. This is where the result goes.
  4. Type =CORREL( and then drag to select your first range, or type it, for example A2:A51. Add a comma.
  5. Select the second range, for example B2:B51, close the bracket, and press Enter. The finished formula looks like =CORREL(A2:A51,B2:B51). Both ranges must have the same number of cells.
  6. Read the number. Positive means one variable tends to rise as the other rises; negative means it tends to fall. Closer to 1 or -1 is a stronger straight-line relationship. Around 0 means no linear relationship, though there may still be a curved one.
  7. Format it for readability. Select the result cell, open the Home tab, and use the Increase Decimal button (or Format Cells > Number) to show two or three decimal places.
  8. Optional: confirm with the alternatives. =PEARSON(A2:A51,B2:B51) returns the same Pearson r as CORREL. =RSQ(A2:A51,B2:B51) returns r squared, the proportion of variance shared by the two variables. If your data are ranks rather than measurements, use Spearman's rho instead: wrap each range in RANK.AVG across the full column, then run CORREL on the ranks. For a full table of pairwise correlations across several variables, the Data Analysis ToolPak's Correlation tool does the work at once, once you have enabled it under File > Options > Add-ins.
  9. To test several variable pairs quickly, copy the formula and lock the ranges with dollar signs, then drag. For example, =CORREL($A$2:$A$51,B$2:B$51) keeps the x range fixed while the y range shifts.

Common Mistakes

The most frequent error is mismatched range sizes: =CORREL(A2:A51,B2:B50) returns #N/A, so check both ranges end on the same row. The second is including header text inside the range, which Excel skips in some cases and counts as text in others, giving a result that does not match your data view. The third is unpaired sorting, where one column gets reordered and the rows no longer correspond. The fourth is drawing conclusions from a tiny sample: five points can produce a correlation near 1 purely by chance. The fifth is treating correlation as causation; two variables can move together because a third factor drives both. Finally, watch for outliers and curved relationships: a single extreme point can drag r towards zero or inflate it, and a clear curve (like a U) can show r near 0 despite a strong pattern. Plot the data on a scatter chart before trusting the number.

Tips

Always build an XY scatter chart alongside the formula; the visual shape tells you whether a straight-line measure is even appropriate. Keep raw data on its own sheet and put formulas on a separate analysis sheet, so accidental edits to the data column do not break the layout. Note the sample size somewhere near the result, because r from 10 pairs and r from 500 pairs carry very different weight. If you need to know whether the correlation is statistically significant, use the t-test conversion available in Excel's Data Analysis ToolPak or run a regression, which reports the p-value directly. Round only for display and keep the underlying value unrounded for any further calculation.

Troubleshooting

If you see #N/A, the two ranges have different lengths or one contains text where a number should be. If you see #DIV/0!, one of the variables has zero variance: every value in that column is identical, so there is nothing to correlate. If Excel treats your numbers as text, they will be left-aligned and the formula may return an error or a wrong count; select the column and use Data > Text to Columns, or multiply the range by 1 with Paste Special, to convert them to real numbers. If the result seems implausible, compare it against a scatter chart and check a handful of rows by eye to confirm the pairs line up. If the formula returns a value that will not update, check that calculation is set to Automatic under Formulas > Calculation Options. When the ranges are correct but the number changes every time you open the file, look for a stray edit or a partially selected range in the formula bar.

Frequently Asked Questions

Which Excel function gives the correlation coefficient?

CORREL is the standard choice and returns Pearson's r. PEARSON returns the same result. Use RSQ when you want r squared instead.

What range of values should I expect?

Anywhere from -1 to 1. A value outside that range means the formula is pointing at the wrong data.

Does CORREL handle blank cells?

It ignores pairs where either cell is empty or text, so blanks reduce the effective sample rather than causing an error. Mismatched range lengths, however, produce #N/A.

How do I correlate more than two columns at once?

Enable the Data Analysis ToolPak and use its Correlation tool, which builds a full matrix. The individual CORREL formulas also work but need one per pair.

Can I use correlation for ranked data?

Yes, but use Spearman's rho: rank both columns with RANK.AVG, then run CORREL on the ranks. It is more appropriate than Pearson's r for ordinal data.

Does a high correlation prove one thing causes another?

No. Correlation measures how closely two variables move together on a straight line, nothing more. A third factor or coincidence can produce a strong correlation.