+ Reply to Thread
Results 1 to 5 of 5

Return sum of all columns that contain specified text and other conditions

  1. #1
    Registered User
    Join Date
    01-22-2018
    Location
    Halifax
    MS-Off Ver
    365
    Posts
    3

    Return sum of all columns that contain specified text and other conditions

    Hi there,

    I have researched this thoroughly and I can't seem to work this one out, any assistance deeply appreciated.

    End result, I would like to return a single number in a A1 on "Sheet1".

    On "Sheet2", Row1 contains headers. Rows 2 and beyond contain 0's, 1's, or blank cells.

    Example of Sheet2:

    ("B" will stand for blanks, not the letter B, below)

    ROW 1: AA GH AR BH AL TK
    ROW 2: 0 B 1 1 B 1
    ROW 3: 1 1 0 B 1 0
    ROW 4: 0 0 1 0 B 1

    ..etc

    I would like to write a formula in A1 on Sheet 1 that returns the sum of all columns in Sheet2 for which the header contains the letter "A" (in the above example the correct value returned would be "5" because AA contains one 1, AR contains two 1's, and AL contains ONE 1's). My apologies for not having that line up tidier.

    Is this possible? I have tried various versions of SUMIFS, INDEX, MATCH, and SUMPRODUCT but i have hit a wall with each new idea I have had.




    For added context, and if anyone really wants to help take me the full way on this one if the above is solved. Not only will I want Sheet1 A1 to return a sum conditional on the column headers, but also:

    - Only among rows for which yet other additional columns of each same row (let's say the header of those columns are XYZ ZYX) contain a 1, and
    - The determination as to whether columns XYZ, or ZYX, or both, act as a filter is based on whether the user has clicked a CheckBox (ActiveX Control).
    That is, if "CheckBoxXYZ" is checked but "CheckBoxZYX" is not, then the number returned in Sheet1 A1 is the sum of all rows for which the column header contains "A" (wildcard), there is a 1 in column XYZ, and there is not a 1 in column ZYX. And so on.

    Any help with either or both of these pieces would be very much appreciated!!!

    Best,
    Brenden
    Last edited by bsommerhalder; 01-22-2018 at 08:43 AM.

  2. #2
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Return sum of all columns that contain specified text and other conditions

    Welcome to the forum, bsommerhalder

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  3. #3
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,207

    Re: Return sum of all columns that contain specified text and other conditions

    Try

    =SUMPRODUCT((A2:F4)*--(ISNUMBER(SEARCH("A",A1:F1))))

    Headings in Row 1

    data in 2 to 4

  4. #4
    Registered User
    Join Date
    01-22-2018
    Location
    Halifax
    MS-Off Ver
    365
    Posts
    3

    Re: Return sum of all columns that contain specified text and other conditions

    Quote Originally Posted by JohnTopley View Post
    Try

    =SUMPRODUCT((A2:F4)*--(ISNUMBER(SEARCH("A",A1:F1))))

    Headings in Row 1

    data in 2 to 4
    John, thank you! Yes, this is exactly what I was asking for. I am extremely grateful.

    I hope it is not too much to ask you, or anyone else equally kind and talented, to help me take it a step further. I have implemented your solution into a fully analogous example and attached it in the attached workbook.

    What I am looking to do is add additional conditions to the formulas in C2:D3 that would, in addition to the solution you (John) provided, also check Sheet2!HeaderRange for the text contained in Sheet1!Column A of each row, AND whether column XYZ contains a 1 in Sheet2, because the XYZ checkbox is checked.

    Therefore in Sheet1!C1, for example, the sum returned would be that of the cells in Sheet1 for which the column header contained both "A" and "01_01", and for which the cell's row contains a 1 in the XYZ column in Sheet2 <-- this latter condition existing by virtue of the "XYZ" checkbox being checked.

    Once again, with only gratitude,
    Brenden
    Attached Files Attached Files
    Last edited by bsommerhalder; 01-22-2018 at 09:18 AM.

  5. #5
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: Return sum of all columns that contain specified text and other conditions

    c2=SUMPRODUCT((DataRange)*--(ISNUMBER(SEARCH("*"&C$1&"*_"&$A2,HeaderRange))))
    Try this and copy across

+ 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. Nested IF to return text string based on certain conditions
    By Mikeyabosbht in forum Excel General
    Replies: 4
    Last Post: 09-06-2017, 05:36 PM
  2. [SOLVED] Lookup the date and return the latest value under some conditions from multiple columns
    By PMH2384 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-09-2016, 03:31 AM
  3. [SOLVED] Return text string for a variety of different conditions
    By Terry-J in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-25-2014, 03:40 PM
  4. if two conditions are met , can I return a text message in another collumn?
    By tzahranul in forum Outlook Formatting & Functions
    Replies: 4
    Last Post: 06-22-2012, 03:16 AM
  5. Replies: 2
    Last Post: 06-21-2012, 05:12 PM
  6. Replies: 3
    Last Post: 11-24-2011, 09:55 AM
  7. Replies: 5
    Last Post: 03-02-2011, 08:56 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