+ Reply to Thread
Results 1 to 6 of 6

Column inserts may or may not adjust SUM formulas following the insert.

  1. #1
    Registered User
    Join Date
    12-17-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Office Professional Plus 2021
    Posts
    18

    Column inserts may or may not adjust SUM formulas following the insert.

    I have noticed that when I manually insert a new column, the following SUM column gets automatically adjusted correctly, which is what I expect. However, the SUM column is not corrected if I insert the column using an Excel macro.


    SETUP
    1. columns C thru H contain client data and column I cells are set to SUM($Cx:Hx) where x is the row number
    2. insert a new client column I to the left of the current I column, which pushes the old SUM column I to column J

    OUTCOMES
    1. via manually - the SUM column J now reads SUM($Cx:Ix) (correct)
    2. via macro - the SUM column still shows SUM($Cx:Hx) (incorrect)


    What am I missing here? I had to then write more VBA code using the Find/Replace function to change all column J formulas from :H's to :I's. My macro works but I must be missing some logical flag set or something. Any ideas?

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

    Re: Column inserts may or may not adjust SUM formulas following the insert.

    Try this in Ix

    =SUM(Cx:INDEX(x:x,COLUMN()-1))

  3. #3
    Registered User
    Join Date
    12-17-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Office Professional Plus 2021
    Posts
    18

    Re: Column inserts may or may not adjust SUM formulas following the insert.

    Very clever, but any ideas why the macro insert column works differently than a manual insert column action?

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

    Re: Column inserts may or may not adjust SUM formulas following the insert.

    I manually insert a new column in I column, but the formula is also =SUM($C1:H1) , not =SUM($C1:I1).

  5. #5
    Registered User
    Join Date
    12-17-2023
    Location
    Indianapolis, IN
    MS-Off Ver
    Office Professional Plus 2021
    Posts
    18

    Re: Column inserts may or may not adjust SUM formulas following the insert.

    [SOLVED]Wow, you are correct. My error in testing was inserting in the middle of the columns. That does adjust the SUM formula but inserts just to the left of the SUM column does not. I made a rookie mistake. Thank you so much for your response.

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

    Re: Column inserts may or may not adjust SUM formulas following the insert.

    You are welcome.
    --------------------------------------
    If that takes care of your original question, please click on "Thread Tools" from the menu link above and mark this thread as SOLVED.

+ 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. Excel Macro inserts row but does not insert next number in row.
    By Man Help in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 12-21-2023, 01:31 AM
  2. [SOLVED] Insert shift:=xlDown inserts junks on the sheet
    By Karen16 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-07-2017, 10:19 AM
  3. [SOLVED] Insert Pivot Table only inserts a blank sheet
    By Dave H in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 09-21-2015, 01:58 PM
  4. [SOLVED] When user inserts new row - need formulas from row above to appear
    By Masun in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-12-2014, 07:31 AM
  5. Replies: 3
    Last Post: 10-10-2012, 09:14 AM
  6. [SOLVED] Selection.EntireRow.Insert Inserts too many Rows!
    By nickv02 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-30-2012, 11:40 AM
  7. [SOLVED] adjust the range in a long column of formulas to accomodate new da
    By Shannon in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-11-2006, 06:05 PM

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