Copy Formulas in Excel
Excel makes it easy to copy your formula across an entire row or column, but you don't always get the results you want. If you end up with unexpected results, or those awful #REF and /DIV0 errors, read about absolute and relative cell references to understand what went wrong. But don't worry: you don't need to edit your 5,000 line spreadsheet cell by cell before you can copy-paste again. There are easy ways to get the formula to update automatically based on its location, or to copy it exactly without changing a single value.
Contents
Steps
Copying a Formula into Multiple Cells by Dragging
- Enter the formula into one cell. As with any formula, start with an = sign, then use whichever functions or arithmetic you'd like. We'll use a simple example spreadsheet, and add column A and column B together: Template:TablePlain
- Press enter to calculate the formula. Once you hit enter on your keyboard, the formula will be entered and calculated. Only the result (19) will be displayed, but the spreadsheet will still have the formula stored. Template:TablePlain
- Click on the lower right corner of the cell to be propagated. Move your cursor to the lower right corner of the cell you just edited. The cursor will become a bold + sign.
- Hold and drag along the column or row you're copying to. Keep your mouse button held down, and drag your cursor down the column, or across the row to be edited (highlight). The formula you entered will automatically be entered into the cells you've highlighted. Relative cell references will automatically update to refer to the cell in the same relative position. Here's our example spreadsheet, showing the formulas used and the results displayed: Template:TablePlain Template:TablePlain
- Double click the plus sign to fill the entire column.
Instead of click-and-dragging, move your mouse to the lower right corner, and double click when the cursor turns into a + sign. This will automatically copy the formula to the entire column.
- Excel will stop filling out the column if it sees an empty cell. If the reference data contains a gap, you will have to repeat this step to fill out the column below the gap.
Copying a Formula into Multiple Cells by Pasting
- Enter the formula into one cell. As with any formula, start with an = sign, then use whichever functions or arithmetic you'd like. We'll use a simple example spreadsheet, and add column A and column B together: Template:TablePlain
- Press enter to calculate the formula. Once you hit enter on your keyboard, the formula will be entered and calculated. Only the result (19) will be displayed, but the spreadsheet will still have the formula stored. Template:TablePlain
- Click on the cell to be propagated and copy it (CTRL+C).
- Select the cells you want to copy the formula to. Click on one and drag up or down using your mouse or the arrow keys. Unlike with the corner drag method, the cells you are copying the formula to do not need to be adjacent to the cell you are copying from.
- Paste (CTRL+V).
Copying a Formula Exactly
- Use this method to quickly copy a formula without changing the cell references. Sometimes, you have a large spreadsheet full of formulas, and you want to copy them exactly. Changing everything to absolute cell references (as described in the section on cell references) would be tedious, especially if you just want to change them back again afterward. Use this method to quickly move formulas with relative cell references elsewhere without changing the references.Template:TablePlain
- If you're just trying to copy the formula in a single cell, skip to the last step ("Try alternate methods") in this section.
Here's our example spreadsheet, which needs to have column C duplicated to column D:
- Open the Find window. On most versions of Excel, you can find this by clicking the Home tab at the top of the Excel window, then clicking Find & Select in the "Editing" portion of the tab. You can also use the keyboard shortcut, CTRL F.
- Find and replace "=" with another character. Enter "=", click "Find All," then enter another character into the "Replace with" box. This will automatically turn all formulas (which always begin with =) into text strings beginning with some other character. Always use a character that you have not used in your spreadsheet. For example, replace it with # or &, or a longer string of characters, such as ##&.
Template:TablePlain
- Do not use the characters * or ?, since these will make later steps more difficult.
- Copy and paste the cells. You may now select any cells you wish to copy, then paste them into another location. Since they are no longer interpreted as formulas, they will be copied exactly. Template:TablePlain
- Use Find & Replace again to reverse the change. Now that you have the formulas where you want them, use the "Find all" and "Replace with" options to reverse your change. In our example, we'll look for the character string "##&" and replace it with "=" again, so those cells become formulas once again. You can now continue editing your spreadsheet as usual: Template:TablePlain
- Try alternate methods. If the method described above does not work for any reason, or if you are worried about accidentally changing other cell contents with the "Replace all" option, there are a couple other methods you can try:
- To copy a single cell's formula without changing references, select the cell, then copy the formula shown in the formula bar near the top of the window (not in the cell itself). Press esc to close the formula bar, then paste the formula wherever you need it.
- Press Ctrl` (usually on the same key as ~) to put the spreadsheet in formula view mode. Copy the formulas and paste them into a text editor such as Notepad or TextEdit. Copy them again, then paste them back into the spreadsheet at the desired location. Press Ctrl` again to switch back to regular viewing mode.
Using Relative and Absolute Cell References
- Use a relative cell reference in a formula. In an Excel formula, a "cell reference" is the address a cell. You can type these in manually, or click on the cell you wish to use while you are entering a formula. For example, the following spreadsheet has a formula that references cell A2: Template:TablePlain
- Understand why they're called relative references. In an Excel formula, a relative reference uses the relative position of a cell address. For example: cell C2 has the formula “=A2”, which is a relative reference to the value two cells to the left. If you copy the formula into cell C4, then it will still refer to two cells to the left, now showing “=A4”.
Template:TablePlain
- This works for cells outside of the same row and column as well. If you copied the same formula from cell C1 into cell D6 (not shown), Excel would change the reference "A2" to a cell one row to the right (C→D) and 5 rows below (2→7), or "B7".
- Use an absolute reference instead. Let's say you don't want Excel to automatically change your formula. Instead of using a relative cell reference, you can make it absolute by adding a $ symbol in front of the column or row that you want to keep the same, no matter where you copy the formula too.Template:TablePlain Template:TablePlain Template:TablePlain Here are a few example spreadsheets, showing the original formula in larger, bold text, and the result when you copy-paste it to other cells:
- Use the F4 key to switch between absolute and relative. Highlight a cell reference in a formula by clicking it. Press F4 on your keyboard, and $ symbols will automatically be added or removed. Keep pressing F4 until the absolute or relative references you'd like are selected, then hit enter.
Tips
- If you copy a formula to a new cell and see a green triangle, Excel has detected a possible error. Examine the formula carefully to see if anything went wrong.
- If you accidentally did replace the = character with ? or * in the "copying a formula exactly" method, searching for "?" or "*" will not give you the results you expect. Correct this by searching for "~?" or for "~*" instead.
- Select a cell and press Ctrl' (apostrophe) to fill it with the formula directly above it.
Warnings
- Different versions of Excel may not show exactly the same screenshots in the same ways as are displayed here.
Related Articles
- Use Summation Formulas in Microsoft Excel
- Create a Drop Down List from a Range of Cells in Excel 2003
- Edit the Contents of a Spreadsheet Cell
- Write a Simple Macro in Microsoft Excel
Sources and Citations
- https://www.youtube.com/watch?v=Dq4khIULb6Q
- ↑ http://www.pryor.com/blog/copy-excel-formulas-down-to-fill-a-column/
- http://www.extendoffice.com/documents/excel/598-excel-copy-without-changing-formulas.html
- ↑ http://office.microsoft.com/en-us/excel-help/find-or-replace-text-and-numbers-on-a-worksheet-HP001216390.aspx
- ↑ http://www.quepublishing.com/articles/article.aspx?p=2024309&seqNum=4
- http://spreadsheetpage.com/index.php/tip/making_an_exact_copy_of_a_range_of_formulas_take_2
- ↑ http://office.microsoft.com/en-us/excel-help/move-or-copy-a-formula-HP010102342.aspx