+ Reply to Thread
Results 1 to 8 of 8

Automatically expand formula when adding coumns

  1. #1
    Registered User
    Join Date
    11-25-2023
    Location
    Midwest, USA
    MS-Off Ver
    Office 21
    Posts
    2

    Automatically expand formula when adding coumns

    I have a spreadsheet, not a table, of 5 rows and multiple columns. There are no column or row names – just data.
    Each column represents a week.
    In the final column of the spreadsheet is a calculation that subtracts the current week from the prior week for each row.
    For example, if I had two columns or two weeks the formula in the third column would be =SUM(A2–A1),=SUM(B2-B1),…,=SUM(E2-E1) for each row.
    If I add a third week or a third column, I would change the formula in the fourth column to =SUM(A3-A2),=SUM(B3-B2),…,=SUM(E3-E2) for each row.
    I would like the formula to automatically update for all rows each time I add a new week or column as opposed to manually updating it.
    Thank you.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2507 (Windows 11 Home 24H2 64-bit)
    Posts
    91,881

    Re: Automatically expand formula when adding coumns

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-25-2023
    Location
    Midwest, USA
    MS-Off Ver
    Office 21
    Posts
    2

    Re: Automatically expand formula when adding coumns

    I think I attached it correctly.
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,988

    Re: Automatically expand formula when adding coumns

    You can use table format to solve it.
    1. Create a "TABLE1" table with header WEEK1, WEEK2, DIFF.
    2. C2 =[@WEEK2]-[@WEEK1]

    See attachment.
    Attached Files Attached Files

  5. #5
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,497

    Re: Automatically expand formula when adding coumns

    please try:
    for this the total column is included in the array (A:C) this will make sure the range is extended always.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Automatically expand formula when adding coumns

    Try.
    In C1 copied down.
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    When you want to insert data in 3rd column insert new column. Now formula will shift to column 4. Fill data in column 3.
    Formula holds good for column 3 and 2. Pl see Sheet2.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,011

    Re: Automatically expand formula when adding coumns

    You said
    I have a spreadsheet, not a table, of 5 rows and multiple columns. There are no column or row names – just data
    Yet the example you posted is of a Structured Table with headers.

    Do you have a Table or not?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,011

    Re: Automatically expand formula when adding coumns

    With no table and no headers

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Or, all in one go (clear the output area before entering the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro: how to automatically expand a formula until there is no more data?
    By AnnieMcken in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-11-2013, 03:34 PM
  2. [SOLVED] Macro to Automatically Expand Print Area
    By djacobsen21 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2013, 09:18 AM
  3. Formatting to automatically expand row height
    By jholmstrom21 in forum Excel General
    Replies: 7
    Last Post: 05-17-2012, 04:08 PM
  4. [SOLVED] Expand Sum Automatically
    By timbo1957 in forum Excel General
    Replies: 6
    Last Post: 03-07-2012, 11:31 AM
  5. Programming a cell to automatically expand when required
    By FloraLina in forum Excel General
    Replies: 5
    Last Post: 08-07-2010, 10:46 AM
  6. References, automatically expand?
    By dan1402 in forum Excel General
    Replies: 5
    Last Post: 07-11-2010, 08:19 AM
  7. Formula to automatically expand each week as new data comes in
    By xlguy in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 06-12-2007, 11:04 AM
  8. Howto have a formula expand automatically?
    By saabman in forum Excel General
    Replies: 1
    Last Post: 03-28-2007, 10:18 AM

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