+ Reply to Thread
Results 1 to 11 of 11

Automate sum of every second cell in same row.

  1. #1
    Registered User
    Join Date
    03-16-2017
    Location
    Victoria, Australia
    MS-Off Ver
    15.26
    Posts
    4

    Automate sum of every second cell in same row.

    Hi guys,

    Please see the attached photo.
    Screen Shot 2017-03-16 at 10.37.26 pm.png

    In row 2, I will be constantly entering figures in every second cell (B2, D2, F2 etc.). In cell B5 will be where the total of those figures will be. Cells C2, E2, G2 etc. will have values that won't be part of the calculation. I am seeking for a formula that will AUTOMATE the sum of the cells B2, D2, F2, H2, J2 etc.

    Thanks
    Last edited by dexcel99; 03-16-2017 at 08:26 AM.

  2. #2
    Registered User
    Join Date
    06-21-2013
    Location
    Wiltshire, UK
    MS-Off Ver
    365 Version 2210 Build 16.0.15726.20070
    Posts
    72

    Re: Automate sum of every second cell in same row.

    i might be missing something here, but surely =SUM(B2, D2, F2, H2, J2) or =SUM(B2:J2) would work? Even B2+D2+F2...


    Ah, think i see what i was missing. Will you be constantly adding to the row over time?

    So just SUM(2:2)
    Last edited by isskint; 03-16-2017 at 08:01 AM.
    Isskint, i get satisfaction out of helping others

  3. #3
    Registered User
    Join Date
    03-16-2017
    Location
    Victoria, Australia
    MS-Off Ver
    15.26
    Posts
    4

    Re: Automate sum of every second cell in same row.

    Sorry. I forgot to mention that cells C3, E2, G2 etc will have a value that won't be part of the calculation.

    Thanks though

  4. #4
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Automate sum of every second cell in same row.

    Try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  5. #5
    Registered User
    Join Date
    03-16-2017
    Location
    Victoria, Australia
    MS-Off Ver
    15.26
    Posts
    4
    Quote Originally Posted by k64 View Post
    Try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks. It worked. Is it possible to make the range the entire second row, so whenever I add data in the seoond row, I won't have to change the formula?
    Last edited by dexcel99; 03-16-2017 at 07:08 PM.

  6. #6
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Automate sum of every second cell in same row.

    Quote Originally Posted by dexcel99 View Post
    Thanks. It worked. Is it possible to make the range the entire second row, so whenever I add data in the second row, I won't have to change the formula?
    You are generally better off dynamically referencing your data instead of using whole row/column/sheet references. You could accomplish this several ways. A table and structured references may work, a dynamic named range, or even a static named range with a pretty high ceiling for the number of columns. All these would limit the number of calculations the formula(s) need to do over blank cells if any.

    Hope this helps

    Edit: Will the row above your values always have a date above the ones you want to sum and nothing or a non date value above the values you do not wish to sum?

  7. #7
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Automate sum of every second cell in same row.

    See attached for my example including dynamic named range

    formula on sheet to SUM
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Named range formula (ValuesRng)
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    *Note the ISBLANK part...if you have continuous data going across until you make new entries then this could be simplified.

    If you have continuous data from B2 to the right (not leaving blanks between even columns):
    Replace (the whole last argument of OFFSET):
    Formula: copy to clipboard
    Please Login or Register  to view this content.


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


    You could of course adjust the columns threshold by changing "V2" to whatever column off to the right you choose. I would encourage you to not extend it to the last column. If you feel like you might have 500 columns, make it 600, 1000, etc. Something high enough you will rarely if ever need to update but not so high we make the formula look at a ton of empty columns you will never reasonably use.

    Hope this helps.
    Attached Files Attached Files
    Last edited by Zer0Cool; 03-16-2017 at 08:03 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Automate sum of every second cell in same row.

    You can do the whole row, it will just slow down the formula. You can also do the whole row if you use SUMIFS, but you'll need to add a helper row with something like "=MOD(COLUMN(),2)". You can also do the dynamic range thing or just put a range larger than you'll ever need.

  9. #9
    Forum Moderator vlady's Avatar
    Join Date
    09-22-2011
    Location
    Philippines - OLSHCO -Guimba-Nueva Ecija
    MS-Off Ver
    2021
    Posts
    4,366

    Re: Automate sum of every second cell in same row.

    YTD on year?Month? or just sum which ignores blank.
    I think people forget the word "THANK YOU!!!!" Do you still know it???

    There is a little star ( ADD REPUTATION ) below those person who helped you. Click it to say your "PRIVATE APPRECIATION TO THEIR EFFORT ON THEIR CONTRIBUTIONS "

    Regards,
    Vladimir

  10. #10
    Forum Moderator
    Join Date
    01-21-2014
    Location
    St. Joseph, Illinois U.S.A.
    MS-Off Ver
    Office 365 V 2503
    Posts
    13,702

    Re: Automate sum of every second cell in same row.

    Another way.

    This dynamic named range formula.
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    You can generally get away referencing whole columns and row with MATCH when return type is approximate.

    Then the formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Dave

  11. #11
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Automate sum of every second cell in same row.

    Quote Originally Posted by dexcel99
    You suggested to use the following formula:
    =SUMPRODUCT(B2:H2*(MOD(COLUMN(B2:H2),2)=0))

    Could you please explain how the values of c2, e2, g2 etc. (every second cell) are not affecting the formula? Also what effect does equating the formula to zero have?
    I understand what the functions do individually.
    Here are the parts of the formula:
    SUMPRODUCT - Perform multiplication, then add up the results
    B2:H2 - The numbers you want to SUM (every other)
    MOD - Remainder when divided by a number
    COLUMN - Column number of a cell (A=1, B=2...)
    *(A=B) - Logical expressions evaluate to TRUE=1 or FALSE=0.

    In English, this says: For every cell in B2:H2, if it is in an even column (MOD(COLUMN,2)=0) then multiply it by 1, otherwise multiply it by 0. Add up the results.

+ 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. Automate cell-by-cell averaging across multiple worksheets?
    By xu9j2 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-22-2016, 09:33 PM
  2. Find word/phrase within cell & automate putting value in adjacent cell
    By jyeg in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-24-2016, 10:44 AM
  3. [SOLVED] If Yes in one cell, Then automate No in two other cells
    By mmallard in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 04-03-2015, 06:35 PM
  4. [SOLVED] Automate a cell to show an answer if another cell says something else.
    By Tinwelende in forum Excel Formulas & Functions
    Replies: 32
    Last Post: 05-10-2014, 07:31 AM
  5. [SOLVED] How can I automate the duplication of a row when the use tabs out of the last cell?
    By AAbrams in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2013, 10:56 AM
  6. vba to automate naming cell ranges
    By RAH in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-13-2008, 01:13 PM
  7. Automate cell selection
    By mayanklal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2006, 11:35 AM

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