Insert formula in excel cell

Follow these steps to fill a formula and choose which options to apply:

  1. Select the cell that has the formula you want to fill into adjacent cells.

  2. Drag the fill handle Fill handle across the cells that you want to fill.

    If you don’t see the fill handle, it might be hidden. To display it again:

    1. Click File > Options

    2. Click Advanced.

    3. Under Editing Options, check the Enable fill handle and cell drag-and-drop box.

  3. To change how you want to fill the selection, click the small Auto Fill Options icon Button image that appears after you finish dragging, and choose the option that want.

For more information about copying formulas, see Copy and paste a formula to another cell or worksheet.

Fill formulas into adjacent cells

You can use the Fill command to fill a formula into an adjacent range of cells. Simply do the following:

  1. Select the cell with the formula and the adjacent cells you want to fill.

  2. Click Home > Fill, and choose either Down, Right, Up, or Left.

    Keyboard shortcut:    You can also press Ctrl+D to fill the formula down in a column, or Ctrl+R to fill the formula to the right in a row.

Turn workbook calculation on

Formulas won’t recalculate when you fill cells if automatic workbook calculation isn’t enabled.

Here’s how you can enable it:

  1. Click File > Options.

  2. Click Formulas.

  3. Under Workbook Calculation, choose Automatic.

  1. Select the cell that has the formula you want to fill into adjacent cells.

  2. Drag the fill handle fill handle down or to the right of the column you want to fill.

Keyboard shortcut: You can also press Ctrl+D to fill the formula down a cell in a column, or Ctrl+R to fill the formula to the right in a row.

Formulas are the life and blood of Excel spreadsheets. And in most cases, you don’t need the formula in just one cell or a couple of cells.

In most cases, you would need to apply the formula to an entire column (or a large range of cells in a column).

And Excel gives you multiple different ways to do this with a few clicks (or a keyboard shortcut).

Let’s have a look at these methods.

By Double-Clicking on the AutoFill Handle

One of the easiest ways to apply a formula to an entire column is by using this simple mouse double-click trick.

Suppose you have the dataset as shown below, where want to calculate the commission for each sales rep in Column C (where the commission would be 15% of the sale value in column B).

Dataset to apply formula to an entire column

The formula for this would be:

=B2*15%

Below is the way to apply this formula to the entire column C:

  1. In cell A2, enter the formula: =B2*15%Formula to calculate the commission
  2. With the cell selected, you will see a small green square at the bottom-right part of the selection. Fill handle in cell selection
  3. Place the cursor over the small green square. You will notice that the cursor changes to a plus sign (this is called the autofill handle)Cursor changes to plus icon
  4. Double click the left mouse keyDouble click on apply formula to the entire column

The above steps would automatically fill the entire column till the cell where you have the data in the adjacent column. In our example, the formula would be applied till cell C15

For this to work, there shouldn’t be data in the adjacent column and there should not be any blank cells in it. If, for example, there is a blank cell in column B (say cell B6), then this auto-fill double click would only apply the formula till cell C5

Fill handle stop when it encounters a blank cell

When you use the autofill handle to apply the formula to the entire column, it’s equivalent to copy-pasting the formula manually. This means that the cell reference in the formula would change accordingly.

For example, if it’s an absolute reference, it would remain as is while the formula is applied to the column, add if it’s a relative reference, then it would change as the formula is applied to the cells below.

By Dragging the AutoFill Handle

One issue with the above double click method is that it would stop as soon as it encountered a blank cell in the adjacent columns.

If you have a small data set, you can also manually drag the fill handle to apply the formula in the column.

Below are the steps to do this:

  1. In cell A2, enter the formula: =B2*15%
  2. With the cell selected, you will see a small green square at the bottom-right part of the selection
  3. Place the cursor over the small green square. You will notice that the cursor changes to a plus signCursor changes to plus icon
  4. Hold the left mouse key and drag it to the cell where you want the formula to be applied
  5. Leave the mouse key when done

Using the Fill Down Option (it’s in the ribbon)

Another way to apply a formula to the entire column is by using the fill down option in the ribbon.

For this method to work, you first need to select the cells in the column where you want to have the formula.

Below are the steps to use the fill down method:

  1. In cell A2, enter the formula: =B2*15%
  2. Select all the cells in which you want to apply the formula (including cell C2)Select the entire column or the range
  3. Click the Home tabClick the Home tab
  4. In the editing group, click on the Fill iconClick on the Fill icon
  5. Click on ‘Fill down’Click on Fill down option

The above steps would take the formula from cell C2 and fill it in all the selected cells

Adding the Fill Down in the Quick Access Toolbar

If you need to use the fill down option often, you can add that to the Quick Access Toolbar, so that you can use it with a single click (and it’s always visible on the screen).

T0 add it to the Quick Access Toolbar (QAT), go to the ‘Fill Down’ option, right-click on it, and then click on ‘Add to the Quick Access Toolbar’

add to quick access toolbar

Now, you will see the ‘Fill Down’ icon appear in the QAT.

Fill Down added to Quick Access toolbar

Using Keyboard Shortcut

If you prefer using the keyboard shortcuts, you can also use the below shortcut to achieve the fill down functionality:

CONTROL + D (hold the control key and then press the D key)

Below are the steps to use the keyboard shortcut to fill-down the formula:

  1. In cell A2, enter the formula: =B2*15%
  2. Select all the cells in which you want to apply the formula (including cell C2)
  3. Hold the Control key and then press the D key

Using Array Formula

If you’re using Microsoft 365 and have access to dynamic arrays, you can also use the array formula method to apply a formula to the entire column.

Suppose you have a data set as shown below and you want to calculate the Commission in column C.

Below is the formula that you can use:

=B2:B15*15%

Array formula to apply formula to an entire column

This is an Array formula that would return 14 values in the cell (one each for B2:B15). But since we have dynamic arrays, the result would not be restricted to the single-cell and would spill over to fill the entire column.

Note that you cannot use this formula in every scenario. In this case, because our formula uses the input value from an adjacent column and as the same length of the column in which we want the result (i.e., 14 cells), it works fine here.

But if this is not the case, this may not be the best way to copy a formula to the entire column

By Copy-Pasting the Cell

Another quick and well-known method of applying a formula to the entire column (or selected cells in the entire column) is to simply copy the cell that has the formula and paste it over those cells in the column where you need that formula.

Below are the steps to do this:

  1. In cell A2, enter the formula: =B2*15%
  2. Copy the cell (use the keyboard shortcut Control + C in Windows or Command + C in Mac)
  3. Select all the cells where you want to apply the same formula (excluding cell C2)
  4. Paste the copied cell (Control + V in Windows and Command + V in Mac)

One difference between this copy-paste method and all the methods convert below above this is that with this method you can choose to only paste the formula (and not paste any of the formattings).

For example, if cell C2 has a blue cell color in it, all the methods covered so far (except the array formula method) would not only copy and paste the formula to the entire column but also paste the formatting (such as the cell color, font size, bold/italics)

If you want to only apply the formula and not the formatting, use the steps below:

  1. In cell A2, enter the formula: =B2*15%
  2. Copy the cell (use the keyboard shortcut Control + C in Windows or Command + C in Mac)
  3. Select all the cells where you want to apply the same formula
  4. Right-click on the Selection
  5. In the options that appear, click on ‘Paste Special’Click on Paste Special
  6. In the ‘Paste Special’ dialog box, click on the Formulas optionSelect formulas in Paste Special dialog box
  7. Click OK

The above steps would make sure that only the formula is copied to the selected cells (and none of the formattings comes over with it).

So these are some of the quick and easy methods that you can use to apply a formula to the entire column in Excel.

I hope you found this tutorial useful!

Other Excel tutorials you may also like:

  • 5 Ways to Insert New Columns in Excel (including Shortcut & VBA)
  • How to Sum a Column in Excel
  • How to Compare Two Columns in Excel (for matches & differences)
  • Lookup and Return Values in an Entire Row/Column in Excel
  • How to Copy and Paste Columns in Excel?
  • Apply Conditional Formatting Based on Another Column in Excel
  • How to Multiply a Column by a Number in Excel

Write Basic Formulas in Excel

Formulas are an integral part of Excel. As a new learner of Excel, one does not understand the importance of formulas in Excel. However, all the new learners know plenty of built-in formulas but do not know how to apply them.

In this article, we will show you how to write formulas in Excel and dynamically change them when the referenced cell values are changed automatically.

Table of contents
  • Write Basic Formulas in Excel
    • How to Write/Insert Formulas in Excel?
      • Example #1
      • Example #2
    • How to use Built-in Excel Functions?
      • Example #1 – SUM Function
      • Example #2 – AVERAGE Function
    • Things to Remember about Inserting Formula in Excel
    • Recommended Articles

Write-Formula-in-Excel

How to Write/Insert Formulas in Excel?

You can download this Write Formula Excel Template here – Write Formula Excel Template

To write a formula in Excel, you first need to enter the equal sign in the cell where we need to enter the formula. So, the formula always starts with an equal (=) sign.

Example #1

Look at the below data in the Excel worksheet.

Write Formula in Excel Example 1

We have two numbers in A1 and A2 cells, respectively. So, if we want to add these two numbers in cell A3, we must first open the equal sign in the A3 cell.

Example 1.1

Enter the numbers as 525 + 800.

Write Formula in Excel Example 1.2

Press the “Enter” key to get the formula equation’s result.

Example 1.3

The formula bar shows the formula, not the result of the formula.

As you can see above, we have got the result as 1325 as the summation of the numbers 525 and 800. In the formula bar, we can see how the formula has been applied = 525+800.

Now, we will change the A1 and A2 numbers to 50 and 80, respectively.

Write Formula in Excel Example 1.4

Result cell A3 shows the old formula result only. It is where we need to make dynamic cell referenceCell reference in excel is referring the other cells to a cell to use its values or properties. For instance, if we have data in cell A2 and want to use that in cell A1, use =A2 in cell A1, and this will copy the A2 value in A1.read more formulas.

Instead of entering the two cell numbers, give a cell reference only to the formula.

 Example 1.5

Press the “Enter” key to get the result of this formula.

Write Formula in Excel Example 1.6

In the formula bar, we can see the formula as A1 + A2, not the numbers of the A1 and A2 cells. Now, change the numbers of any of the cells. For example, in the A3 cell, it will automatically impact the result.

 Example 1.7

We have changed the A1 cell number from 50 to 100, and because the A3 cell has the reference of the cells A1 and A2, the A3 cell automatically changed.

Example #2

Now, we have other numbers for the adjacent columns.

Write Formula in Excel Example 2

We have numbers in four more columns. We need to get the total of these numbers as we did for A1 and A3 cells.

Example 2.1

It is where the real power of cell-references formulas is crucial in making the formula dynamic. For example, copy cell A3, which has already applied the formula A1 + A2, and paste it to the next cell, B3.

Write Formula in Excel Example 2.2

Look at the result in cell B3. The formula bar says the formula as B1 + B2 instead of A1 + A2.

When we copied and pasted the A3 cell, the formula cell, we moved one column to the right. But in the same row, we have passed the formula. Because we moved one column to the right in the same row-column reference or header value, “A” has been changed to “B,” but row numbers 1 and 2 remain the same.

Copy and paste the formula to other cells to get the total in all the cells.

 Example 2.3

How to use Built-in Excel Functions?

Example #1 – SUM Function

We have plenty of built-in functions in Excel according to the requirements and situations we can use. For example, look at the below data in Excel.

Write Formula in Excel Example 3

We have numbers from the A1 to E5 range of cells. In the B7 cell, we need the total sum of these numbers. Adding individual cell references and entering each cell reference one by one consumes a lot of time, so putting an equal sign open SUM function in excelThe SUM function in excel adds the numerical values in a range of cells. Being categorized under the Math and Trigonometry function, it is entered by typing “=SUM” followed by the values to be summed. The values supplied to the function can be numbers, cell references or ranges.read more.

 Example 3.1

Select the range of cells from A1 to E5 and close the bracket.

Write Formula in Excel Example 3.2

Press the “Enter” key to get the total numbers from A1 to E5.

Example 3.3

In just a fraction of seconds, we got the total numbers. In the formula bar, we can see the formula as =SUM(A1: E5).

Example #2 – AVERAGE Function

Assume you have students” every subject score, and you need to find the student’s average score. It is possible to find an average score in a fraction of seconds. For example, look at the below data.

Write Formula in Excel Example 4

Open AVERAGE function in the H2 cell first.

Example 4.1

Select the range of cells reference as B2 to G2 because for the student “Amit,” all the subject scores are in this range only.

Write Formula in Excel Example 4.2

Press the “Enter” key to get the average student “Amit.”

Example 4.3

So, the student “Amit” average score is 79.

Now, drag formula cell H2 to the below cells to get the average of other students.

Write Formula in Excel Example 4.4

Things to Remember about Inserting Formula in Excel

  • The formula should always start with an equal sign. We can also start with a PLUS or MINUS sign but not recommended.
  • While doing calculations, we need to remember BODMAS’s basic Maths rules.
  • We must always use built-in functions in Excel.

Recommended Articles

This article is a guide to Write Formula in Excel. Here, we discuss how to insert formulas and built-in functions in Excel with examples and a downloadable Excel template. You may learn more about Excel from the following articles: –

  • Evaluate Formula in ExcelThe Evaluate formula in Excel is used to analyze and understand any fundamental Excel formula such as SUM, COUNT, COUNTA, and AVERAGE. For this, you may use the F9 key to break down the formula and evaluate it step by step, or you may use the “Evaluate” tool.read more
  • Marksheet in ExcelMarksheets in Excel help keep records, entries, and tracking the performance of students, candidates, and even employees and workers, thereby, reducing the task of regularizing hundreds of people to a more simple and easy way within the desired format.read more
  • Excel Infographics
  • Excel Hacks

Excel formulas allow you to identify relationships between values in your spreadsheet’s cells, perform mathematical calculations with those values, and return the resulting value in the cell of your choice. Sum, subtraction, percentage, division, average, and even dates/times are among the formulas that can be performed automatically. For example, =A1+A2+A3+A4+A5, which finds the sum of the range of values from cell A1 to cell A5.

Excel Functions: A formula is a mathematical expression that computes the value of a cell. Functions are predefined formulas that are already in Excel. Functions carry out specific calculations in a specific order based on the values specified as arguments or parameters. For example, =SUM (A1:A10). This function adds up all the values in cells A1 through A10.

How to Insert Formulas in Excel?

This horizontal menu, shown below, in more recent versions of Excel allows you to find and insert Excel formulas into specific cells of your spreadsheet. On the Formulas tab, you can find all available Excel functions in the Function Library:

The more you use Excel formulas, the easier it will be to remember and perform them manually. Excel has over 400 functions, and the number is increasing from version to version. The formulas can be inserted into Excel using the following method:

1. Simple insertion of the formula(Typing a formula in the cell):

Typing a formula into a cell or the formula bar is the simplest way to insert basic Excel formulas. Typically, the process begins with typing an equal sign followed by the name of an Excel function. Excel is quite intelligent in that it displays a pop-up function hint when you begin typing the name of the function.

2. Using the Insert Function option on the Formulas Tab:

If you want complete control over your function insertion, use the Excel Insert Function dialogue box. To do so, go to the Formulas tab and select the first menu, Insert Function. All the functions will be available in the dialogue box.

3. Choosing a Formula from One of the Formula Groups in the Formula Tab:

This option is for those who want to quickly dive into their favorite functions. Navigate to the Formulas tab and select your preferred group to access this menu. Click to reveal a sub-menu containing a list of functions. You can then choose your preference. If your preferred group isn’t on the tab, click the More Functions option — it’s most likely hidden there.

4. Use Recently Used Tabs for Quick Insertion:

If retyping your most recent formula becomes tedious, use the Recently Used menu. It’s on the Formulas tab, the third menu option after AutoSum.

Basic Excel Formulas and Functions:

1. SUM:

The SUM formula in Excel is one of the most fundamental formulas you can use in a spreadsheet, allowing you to calculate the sum (or total) of two or more values. To use the SUM formula, enter the values you want to add together in the following format: =SUM(value 1, value 2,…..).

Example: In the below example to calculate the sum of price of all the fruits, in B9 cell type =SUM(B3:B8). this will calculate the sum of B3, B4, B5, B6, B7, B8 Press “Enter,” and the cell will produce the sum: 430. 

2. SUBTRACTION:

To use the subtraction formula in Excel, enter the cells you want to subtract in the format =SUM (A1, -B1). This will subtract a cell from the SUM formula by appending a negative sign before the cell being subtracted.

For example, if A3 was 300 and B3 was 225, =SUM(A1, -B1) would perform 300 + -225, returning a value of 75 in D3 cell.

3. MULTIPLICATION:

In Excel, enter the cells to be multiplied in the format =A3*B3 to perform the multiplication formula. An asterisk is used in this formula to multiply cell A3 by cell B3.

For example, if A3 was 300 and B3 was 225, =A1*B1 would return a value of 67500.

Highlight an empty cell in an Excel spreadsheet to multiply two or more values. Then, in the format =A1*B1…, enter the values or cells you want to multiply together. The asterisk effectively multiplies each value in the formula.

To return your desired product, press Enter. Take a look at the screenshot above to see how this looks.

4. DIVISION:

To use the division formula in Excel, enter the dividing cells in the format =A3/B3. This formula divides cell A3 by cell B3 with a forward slash, “/.”

For example, if A3 was 300 and B3 was 225, =A3/B3 would return a decimal value of 1.333333333.

Division in Excel is one of the most basic functions available. To do so, highlight an empty cell, enter an equals sign, “=,” and then the two (or more) values you want to divide, separated by a forward slash, “/.” The output should look like this: =A3/B3, as shown in the screenshot above.

5. AVERAGE:

The AVERAGE function finds an average or arithmetic mean of numbers. to find the average of the numbers type = AVERAGE(A3.B3,C3….) and press ‘Enter’ it will produce average of the numbers in the cell.

For example, if A3 was 300, B3 was 225, C3 was 180, D3 was 350, E3 is 400 then =AVERAGE(A3,B3,C3,D3,E3) will produce 291.

6. IF formula:

In Excel, the IF formula is denoted as =IF(logical test, value if true, value if false). This lets you enter a text value into a cell “if” something else in your spreadsheet is true or false.

For example, You may need to know which values in column A are greater than three. Using the =IF formula, you can quickly have Excel auto-populate a “yes” for each cell with a value greater than 3 and a “no” for each cell with a value less than 3.

7. PERCENTAGE:

To use the percentage formula in Excel, enter the cells you want to calculate the percentage for in the format =A1/B1. To convert the decimal value to a percentage, select the cell, click the Home tab, and then select “Percentage” from the numbers dropdown.

There isn’t a specific Excel “formula” for percentages, but Excel makes it simple to convert the value of any cell into a percentage so you don’t have to calculate and reenter the numbers yourself.

The basic setting for converting a cell’s value to a percentage is found on the Home tab of Excel. Select this tab, highlight the cell(s) you want to convert to a percentage, and then select Conditional Formatting from the dropdown menu (this menu button might say “General” at first). Then, from the list of options that appears, choose “Percentage.” This will convert the value of each highlighted cell into a percentage. This feature can be found further down.

8. CONCATENATE:

CONCATENATE is a useful formula that combines values from multiple cells into the same cell.

For example , =CONCATENATE(A3,B3) will combine Red and Apple to produce RedApple. 

9. DATE:

DATE is the Excel DATE formula =DATE(year, month, day). This formula will return a date corresponding to the values entered in the parentheses, including values referred to from other cells.. For example, if A2 was 2019, B2 was 8, and C1 was 15, =DATE(A1,B1,C1) would return 15-08-2019.

10. TRIM:

The TRIM formula in Excel is denoted =TRIM(text). This formula will remove any spaces that have been entered before and after the text in the cell. For example, if A2 includes the name ” Virat Kohli” with unwanted spaces before the first name, =TRIM(A2) would return “Virat Kohli” with no spaces in a new cell.

11. LEN:

LEN is the function to count the number of characters in a specific cell when you want to know the number of characters in that cell. =LEN(text) is the formula for this. Please keep in mind that the LEN function in Excel counts all characters, including spaces:

For example,=LEN(A2), returns the total length of the character in cell A2 including spaces.

I am trying to insert a formula into a cell using vba. This formula will need to have references to activecell.row range or dynamic reference.

I am using the following vba code:

Range("P" & ActiveCell.Row).Formula = "=IF(OR(G & ActiveCell.Row <>"",""H"" & ActiveCell.Row <>"",""I"" & ActiveCell.Row <>"",""J"" & ActiveCell.Row <>"",""M"" & ActiveCell.Row <>""),TODAY(),"")"

I get an Application defined or object defined error. Please can someone show me where i am going wrong? Thanks in advance.

asked Oct 16, 2016 at 11:55

M.Doe's user avatar

assuming that what you want is this formula:

=IF(OR(G1<>"",H1<>"",I1<>"",J1<>"",M1<>""),TODAY(),"")

Try this

Range("P" & ActiveCell.Row).Formula = "=IF(OR(G" & ActiveCell.Row & "<>"""",H" & ActiveCell.Row & "<>"""",I" & ActiveCell.Row & "<>"""",J" & ActiveCell.Row & "<>"""",M" & ActiveCell.Row & "<>""""),TODAY(),"""")"

answered Oct 16, 2016 at 12:18

Charles Williams's user avatar

Charles WilliamsCharles Williams

23.1k5 gold badges37 silver badges38 bronze badges

I’d use R1C1 notation and CountA() to simplify a bit

Range("P" & ActiveCell.row).FormulaR1C1 = "=if(counta(RC7:RC10,RC13)>0,Today(),"""")"

answered Oct 16, 2016 at 12:57

user3598756's user avatar

user3598756user3598756

28.8k4 gold badges17 silver badges28 bronze badges

2

I think the issue is with the double-quotes. You have:

...).Formula = "=IF(OR(G & ActiveCell.Row <>"",""H"" & ActiveCell..."

While it should be:

...).Formula = "=IF(OR(G & ActiveCell.Row <>"""",""""H"""" & ActiveCell..."

Remember: In a string enclosed within -«- chars, any appearance of the same char within the string must be doubled.

Didn’t check this though, but I quite sure this is an error (perhaps not THE error).

answered Oct 16, 2016 at 12:01

FDavidov's user avatar

FDavidovFDavidov

3,4136 gold badges22 silver badges58 bronze badges

1

Like this post? Please share to your friends:
  • Insert footnotes in word
  • Inicio de microsoft word
  • Index from word list
  • Insert fill text in word
  • Inherit meaning of the word