Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /homepages/16/d462231950/htdocs/EFC/wp-content/plugins/wp-markdown/markdownify/markdownify.php on line 299

Warning: Declaration of WarpMenuWalker::start_lvl(&$output, $depth) should be compatible with Walker_Nav_Menu::start_lvl(&$output, $depth = 0, $args = Array) in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/system.php on line 678

Warning: Declaration of WarpMenuWalker::end_lvl(&$output, $depth) should be compatible with Walker_Nav_Menu::end_lvl(&$output, $depth = 0, $args = Array) in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/system.php on line 678

Warning: Declaration of WarpMenuWalker::start_el(&$output, $item, $depth, $args) should be compatible with Walker_Nav_Menu::start_el(&$output, $item, $depth = 0, $args = Array, $id = 0) in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/system.php on line 678

Warning: Declaration of WarpMenuWalker::end_el(&$output, $item, $depth) should be compatible with Walker_Nav_Menu::end_el(&$output, $item, $depth = 0, $args = Array) in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/system.php on line 678

Warning: count(): Parameter must be an array or an object that implements Countable in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/system.php on line 61

Warning: session_start(): Cannot start session when headers already sent in /homepages/16/d462231950/htdocs/EFC/wp-content/themes/yoo_sync_wp/warp/systems/wordpress/helpers/config.php on line 48
Always link to the cell above with a simple trick | Excel For Consultants

Always link to the cell above with a simple trick

Written by Peter Albert on . Posted in Advanced user, Expert, Hacks, Shortcuts

Here’s a neat little trick that is really useful: create a named range CellAbove that dynamically links to the cell above the formula – and then use it in formulas where you need to refer to the above cell. E.g. if you want to have a list of years, starting with a (dynamic) start year stored in cell A1, instead of writing =A1+1 in the cell below, use =CellAbove+1. Now copy this formula down. The advantage? If you insert another row somewhere in this range of years, the new formula will still refer to the row above – while the normal formula will refer now two rows above.

So, in order to set up this name, do the following:

  1. Select cell B1
  2. In the “Formula” tab of the ribbon, click on the “Name manager”, select “New”
  3. Enter the name CellAboveas name, select the current worksheet as scope
  4. In the “Refers to field”, select the cell above, i.e. cell A1. Important: Make sure to remove the $ (use F4 to toggle them)
  5. Press “OK” and close the name manager

Use formula "=Sheet1!A1" without $ for the name CellAbove

Small limitation: This name will always refer to the cell above on Sheet1! If you want to use this approach on multiple sheets, repeat the steps above, but replace Sheet1 with the target sheet.

Pro tip: As I use this really often, I create a small macro in my personal macro workbook that does the job – and assigned the macro to CtrlShiftA:

  1. Open the Visual Basic editor (AltF11)
  2. In the tree panel on the left, expand “VBAPRoject (personal.xlsm)”.
  3. Right click “Modules”->”Insert->”Module”
  4. Double click on the new module
  5. Paste the code below in the main code window
  6. Save (CtrlS) the macro and close the editor
  7. In Excel, open the Macro dialog (kbd>Alt–F8, select the macro Personal.xlsm!subAddCellAboveName, click on “Options” and assign a shortcut of your choice.
    Public Sub subAddCellAboveName()
        On Error Resume Next
        ActiveSheet.Names.Add Name:="CellAbove", RefersToR1C1:="=R[-1]C"
    End Sub

Tags: , ,

Trackback from your site.

Peter Albert

Worked 5 years as Consultant and Project Manager at McKinsey & Company and Bain & Company. Now builds Excel, other models and web applications for consultancies and other clients - and provides Excel training to consultants at all skill levels.

Leave a comment

You must be logged in to post a comment.