Fill down in Excel, but based on multiple values

Mr. Excel has the answer for pre-Ribbon versions of Excel. Below are instructions for Excel 2007. With foo/bar in column A and your data in column B:

  1. Select all of the data in column A, from top to bottom.
  2. Click on Home->Find & Select->Go To Special
  3. Click "Blanks" and hit "Ok". (At this point, all blanks in the column should be selected, and cell A2 should be the active cell.)
  4. Press "=", and then press up to select cell A1.
  5. Press CtrlEnter to copy the formula into all selected cells.

Optional Step 7: If you need only the values, copy the whole column and "Paste Special" just values over top.


To do it manually:

Add a column (B) between the foo-bar column (say A) and the number column (now C).

Formula in B1 is something like =A1, in B2 (and copied down to the end of the data) =if(A2="",B1,A2). Column B now has the foo-bars almost as you want them, but they are the result of formulae rather than text.

Copy column B and paste special it into column A as values.

You can now delete column B.

If you get the idea, it's probably quicker to do it than write down the description, but whether you would prefer a Python script or not will depend on the number of spreadsheets...