+ Reply to Thread
Results 1 to 15 of 15

MOD function question

  1. #1
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    MOD function question

    Hi All

    I am currently working with a sample formula as shown below.

    =SUM(IF(MOD(COLUMN($A$1:$O$1),2)=0,$A$1:$O$1,0))

    If I set up numeric data in row 1 (i.e. different numbers in each column of row 1 from column A up to and including column O), the formula works fine in that it returns the sum of every second item on the row.

    Here is the problem - I am trying to use this formula in a spreadsheet where i will have to add columns to the left of column A. (For things like desc or dept etc. The moment I add an odd number of columns, the formulas get skewed by the number of columns I insert before column A. (the function seems to be anchored on counting from column A). Is there a way to make this formula work where you want it to work? In my case. I want it to work at whatever column the numbers start on and then to end on column XFD. Thanks..
    Attached Files Attached Files
    Last edited by BMaxx; 11-16-2022 at 01:54 PM.

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    Maybe this:

    =SUM(IF(MOD(COLUMN($B$1:$XFD$1),2)=IF(ISODD(COLUMN($B$1)),1,0),$B$1:$XFD$1,0))
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    Hi Glenn

    Thanks for your answer. I am actually working with a count of every 5th column for my project. Columns that I add before column A could end up to be odd or even depending on what information I need to add. I could end up with 4,5,6,7,8,9 or more columns before my numbers kick in. Sorry for not clarifying this.

    I would like this formula to be dynamic in that it automatically adjusts for however many columns i end up adding to the left of column A
    Last edited by BMaxx; 11-16-2022 at 12:41 PM.

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    Columns A, E, I or Columns A, F, K (before extra columns are inserted)?

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    Words may be ambiguous. Post a sample sheet showing EXACTLY which cells (from A1 to O1) you DO wish to sum.

  6. #6
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    Glenn - I'll try to attach an example right away

  7. #7
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    OK - how can i attach a file?

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    Read the yellow banner (top of page) about sample sheets.

  9. #9
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    how's that?

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    Umm. No. If you want every 5th column summed... show me a sample with every 5th column summed.

  11. #11
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    A guess:
    =SUM(IF(MOD(COLUMN($A$1:$AFD$1)-COLUMN($A$1)+1,5)=1,$A$1:$AFD$1,0))
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    Hi Glenn

    Uploaded better example.

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    only NOW, do I know that you do not want to start with the first value...

    =SUM(IF(MOD(COLUMN($A$2:$O$2)-COLUMN($A$2)+1,5)=0,$A$2:$O$2,0))

    If needed, change the bit in red. If you do extend it to AFD - when you do not need to, you may notice an adverse effect on performance
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    08-17-2022
    Location
    AB, Canada
    MS-Off Ver
    2016
    Posts
    11

    Re: MOD function question

    Hi Glenn

    Sorry for any confusion on my part but this is the first time i have used this function. I will study your example so as to educate myself. THANKS very much for your help.

    The reason I wanted to extend to XFD was because I also add new number columns on the right. XFD, while extreme, would catch them. I'll see if I can find a workaround.
    Last edited by BMaxx; 11-16-2022 at 02:33 PM.

  15. #15
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,031

    Re: MOD function question

    woo Hoo! We got there.

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please click on "Thread Tools" from the menu link (just above the first post in the thread) 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. A general question on a EXCEL function, how to get Ctl-R function
    By Potholes in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-09-2022, 02:08 AM
  2. Replies: 1
    Last Post: 01-09-2022, 02:08 AM
  3. User Defined function question. for a sigma function
    By thisisaMJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2018, 09:52 AM
  4. [SOLVED] Workbook_BeforeSave Question Function Question
    By thomasmc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-24-2015, 01:44 PM
  5. [SOLVED] IF function combined with another IF function question
    By Nexion21 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-06-2013, 05:13 PM
  6. IF Function Question:SUMIF function
    By VBA Noob in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 10-03-2007, 03:28 PM
  7. function question
    By Cletus Stripling in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-15-2006, 01:55 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