Go Back

Excel VAR Function

The VAR function in Excel estimates the variance of a sample of data, while ignoring empty cells, text and logical values.  This step by step tutorial will assist all levels of Excel users in the usage and syntax of the VAR function.

Figure 1. Final result: Excel VAR function

Final formula: =VAR(B3:B7)

Syntax of the VAR Function


  • number1 – any number, array or cell reference representing a sample of a population whose variance we want to calculate
  • Only number1 is required; succeeding numbers are optional

Setting up the Data

We have here a list of Scores in column B.  We want to calculate the variance of our data in cell E2.

Figure 2. Sample data to calculate variance using VAR function

Calculate variance using VAR function

In order to calculate the variance of the sample of data, we follow these steps:

Step 1. Select cell E2

Step 2. Enter the formula: =VAR(B3:B7)

Step 3. Press Enter

The range B3:B7 contains our data.  The VAR formula calculates the variance and returns 7.30 in cell E2.  

Figure 3. Output: Calculate variance using VAR function


  • VAR function ignores the following: empty cells, logical values {TRUE or FALSE}, text values
  • In order to evaluate logical values or text, we use the VARA function
  • We use VAR when we have a sample of the data; if our data represents the entire population, we use VARP

Below example shows four more cells are added into our list of scores: a text value, an empty cell, and logical values TRUE and FALSE.  Note that the resulting variance calculated by the VAR function is still 7.30, which is the same as in our previous example.

Figure 4. Output: VAR function ignores blank cells, text and logical values

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

Did this post not answer your question? Get a solution from connecting with the expert.

Another blog reader asked this question today on Excelchat:
Here are some problems that our users have asked and received explanations on

function onEdit() { var s = SpreadsheetApp.getActiveSheet(); var r = s.getActiveCell(); if( r.getColumn() != 2 ) { //checks the column var row = r.getRow(); var time = new Date(); time = Utilities.formatDate(time, "GMT+06:00", "MM/DD/YY, hh:mm:ss"); SpreadsheetApp.getActiveSheet().getRange('A' + row.toString()).setValue(time); } }
Solved by F. E. in 21 mins
I have used the countonbgcolor script to count the background color as: function countOnBGColor(range, colorref) { var sheet = SpreadsheetApp.getActiveSheet(); var color = sheet.getRange(colorref) .getBackground(); var range = sheet.getRange(range); var rangeVal = range.getValues(); var count = 0; var allColors = range.getBackgrounds(); for (var i = 0; i < allColors.length; i++) { for (var j = 0; j < allColors[0].length; j++) { if (allColors[i][j] == color) count += 1; }; }; return count; } This works great but it does not update when the the sheet is updated. Is there a way to get the script to function automatically to update the value in change with the background color, even reloading the page doesn't update it. The only way I can get it to update is to change it then change it back. PFA Link.
Solved by K. L. in 29 mins
Hi I need help defining the "length" on line 3 of the code. It does not work on script editor. function result(range) { var output2 = []; for(var i=0, iLen=range.length; i
Solved by I. W. in 24 mins

Leave a Comment