+ Reply to Thread
Results 1 to 19 of 19

Apply Formula to a Whole Column

  1. #1
    Registered User
    Join Date
    11-26-2008
    Location
    Michigan
    Posts
    8

    Apply Formula to a Whole Column

    Hi, this might be a stupid question but is it possible to apply a formula to a whole column just one time, so I don't have to copy/paste it every time I insert a new row?
    Thank you.
    Last edited by VBA Noob; 11-26-2008 at 01:49 PM.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Depends on the formula. Are you talking about a single formula that is doing some comparison ON the whole column, or is it a formula that only applies to one row at a time?

    If you DO need the formula IN each row, you will have to copy it down, but there are a lot of keyboard shortcuts for doing that quickly. Is this a large range?

    You can highlight the cell and grab the little square in the lower right corner and just pull down with your mouse.

    You can CTRL-C to copy the cell, then use your keyboard or mouse to select the entire range you want the cells copied to, press ENTER and it will copy to them all at once.

    If you really want a formula to type itself in everytime you add a row, that will require a MACRO.

    Post the macro question in the Programming Forum and be sure to post the formula itself you want to be copied.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Not a stupid question.

    Normally people copy the formula down further than they need to and just leave it "sticking out".

    For a neater way, try converting your range to a list:
    select the table
    Data->
    List->
    Create list->

    This should add a "new row" row at the bottom of the range, which may remind you of Access if you're used to that.

    Type something in to the first cell of the * line

    This:
    * keeps "tab" inside the table, so you can cycle straight through if you're tapping info in
    * copies any formula down a row when you add a new row
    * impresses women and makes them want to disrobe in front of you*

    HTH

    *Not 100% sure about this one

  4. #4
    Valued Forum Contributor Rahul Nagar's Avatar
    Join Date
    09-18-2008
    Location
    nasik
    MS-Off Ver
    Excel 2003
    Posts
    465
    Hello

    Copy the cell and paste to wherever you want it. One way to fill the whole column (and I do mean the WHOLE column) is click the Column letter at the top of the Column, therefore selecting the whole column, and paste.

    OR select the cell that houses your Formula, and click on the small black box in the bottom right hand corner of the cell. Then drag down to fill.
    __________________
    Regards
    Rahul Nagar
    Founder of www.myshortcutkeys.com.


    If you get the answer of your questions then please click EDIT in your original post then click on GO ADVANCED and set the PREFIX box to SOLVED. It helps everybody! ....
    Also
    If you are satisfied by any members response to your problem please consider using the scales icon top right of thier post to show your appreciation.

  5. #5
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    If you really want a formula to type itself in everytime you add a row, that will require a MACRO.

    Post the macro question in the Programming Forum and be sure to post the formula itself you want to be copied.
    Oh no, no... see my post!

  6. #6
    Registered User
    Join Date
    11-26-2008
    Location
    Michigan
    Posts
    8

    formula

    my formula calculates distance traveled.
    basically what I want it to do is when I insert a new line, just type in the name and the cell on right of it automatically gets a value

    =IF(B23="Post Office",1.8,IF(B23="Gary",3.8,IF(B23="Staples",2.6,IF(B23="Staples",2.6,IF(B23="Bank",2.3,IF(B23="UPS",2.3,IF(B23="Met. Furniture",0.3,0)))))))

    right now it works perfectly but like I said, I have to copy it every time, it doesn't take a lot of time but still, it would be nice if I did not have to do it.

    Also, is there an easier way to make that formula? cause I would imagine if I had 100 destinations it would get pretty messy

    Thank you in advance.

  7. #7
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Search the forum for "vlookup" there's about a million examples.

    Creating a list, as I described, will copy this kind of formula automatically.

    HTH

    PS, you might not get 100 destinations, there is a limit on nesting ifs in XL<=2003 - no more than 7!

    PPS you have Staples in there twice...
    Last edited by Cheeky Charlie; 11-26-2008 at 12:08 PM. Reason: nested ifs won't work anyway

  8. #8
    Registered User
    Join Date
    11-26-2008
    Location
    Michigan
    Posts
    8
    Quote Originally Posted by Cheeky Charlie View Post
    Not a stupid question.

    Normally people copy the formula down further than they need to and just leave it "sticking out".

    For a neater way, try converting your range to a list:
    select the table
    Data->
    List->
    Create list->

    This should add a "new row" row at the bottom of the range, which may remind you of Access if you're used to that.

    Type something in to the first cell of the * line

    This:
    * keeps "tab" inside the table, so you can cycle straight through if you're tapping info in
    * copies any formula down a row when you add a new row
    * impresses women and makes them want to disrobe in front of you*

    HTH

    *Not 100% sure about this one
    I have an older 2000 Excel, I do not have List in my Data, is there a way to do it in my version? or should I just upgrade mine, but I do like this older one cause it works faster and feels familiar.

  9. #9
    Registered User
    Join Date
    11-26-2008
    Location
    Michigan
    Posts
    8
    Quote Originally Posted by Cheeky Charlie View Post
    PPS you have Staples in there twice...
    Thanks, didn't even notice it. but what if I wanted excel to check twice that it is truly staples? lol

  10. #10
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492
    Cheeky, that List approach is new to me. Awesome find. I can put that to work today! Thanks for that.

  11. #11
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Select the range you want your formula to be in (e.g. F2:F250). The first cell (F2) should be white and the others grayed.

    Type in your formula as you would for F2. Then Hold the control key down when you hit enter. The formula will appear in all columns with the cell references changing accordingly.
    Does this work for you?
    ChemistB <- Also on Excel 2000 and wishing I had that List ability
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  12. #12
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    We could do it with a macro as has been alluded to, but I think that's possibly overkill. In lieu of list, I'd just copy the formula beyond where it's needed.

    CC

  13. #13
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    Glad I could teach you something JB!

  14. #14
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Or do Tools > Options > Edit, tick Extend data range formats and formulas. When you enter data in a new row, Excel will magically copy down formulas in the same row from the row above.
    Entia non sunt multiplicanda sine necessitate

  15. #15
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    shg, I though this only works when the user inserts a row, not when a user inserts new data? As far as I can tell, that's how it works for me (xl2003)

    CC

  16. #16
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Enter something (anything) in A9:C9, and see what happens in D9.
    Attached Files Attached Files

  17. #17
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561
    mmm... works only if I put something in every cell

    even your example has a gap...

    CC

  18. #18
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582
    Yep, it only fills in the formula when any cells that the formula refers to are filled in. So if the formula was A5*B5, the formula would appear as soon as A5 and B5 are filled in. Unfortunately, with a Count function, all cells in the count range need to be filled in.

  19. #19
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,372
    shg writes

    Or do Tools > Options > Edit, tick Extend data range formats and formulas. When you enter data in a new row, Excel will magically copy down formulas in the same row from the row above.
    Note that this only works if your list already contains at least 4 rows and it does not work on ALL kinds of formulas. See below info from Microsoft

    When Auto Extended Formulas May Not Work
    Formulas copy down if four of the last five cells contain a similar formula and the cell above the active cell contains the formula that you want copied down. There are times when formulas may not extend. The following list contains examples of formulas that Excel will not copy down.

    - Formulas that reference cells in other sheets or workbooks do not copy down, even if they also reference a cell in the list containing the active cell.
    - Formulas in which all of the formula's references point to areas outside the list.
    - Formulas that reference a dimensional horizontal range in which not all row references are relative, for example:
    =SUM($A$1, A2, B1, B2) Column references have no effect on the copy down trigger.
    - A formula that uses a series reference, where none of the row references are relative, for example:
    =SUM($A$1, $B$1) Column references have no effect on the copy down trigger.
    - Formulas containing a range name or natural language formula.
    - Data that you paste into the new row.

    Most Microsoft Excel functions also copy down, as long as they follow the basic guidelines outlined in this article.
    cheers

    Teylyn
    Last edited by teylyn; 11-26-2008 at 05:39 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1