+ Reply to Thread
Results 1 to 6 of 6

Summing every second field in a row

  1. #1
    Registered User
    Join Date
    10-05-2007
    Posts
    11

    Summing every second field in a row

    Hey,

    I have a problem. I'm supposed to sum values in every second field in a row(and the length of columns that have to be summed varies).

    So basicly I have to SUM(J4,L4,N4,P4.....) and SUM(K4,M4,O4.....) for a variable number of columns.

    Any help?
    Attached Images Attached Images

  2. #2
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Link should help

    http://www.mcgimpsey.com/excel/formu...meverynth.html

    Post back if you can get it to work

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  3. #3
    Registered User
    Join Date
    10-05-2007
    Posts
    11
    Thanks. I am very new to excel, so need some more help. The formula could probably work, but how can I set the "rng"? Will that automaticly be the whole range, or do I need to set it somehow?

    =SUMPRODUCT(MOD(COLUMN(rng);2)*rng)

  4. #4
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Change range as required

    =SUMPRODUCT((1-MOD(COLUMN(J4:Q4),2))*J4:Q4)

    VBA Noob

  5. #5
    Registered User
    Join Date
    10-05-2007
    Posts
    11
    Thanks! That worked I actually tried to set the range that way, but I had something wrong.

    Great

  6. #6
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad it helped.

    Useful link to keep hold of. More links below

    VBA Noob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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