+ Reply to Thread
Results 1 to 13 of 13

How can i make this formula simpler/shorter?

  1. #1
    Registered User
    Join Date
    05-11-2021
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO
    Posts
    4

    How can i make this formula simpler/shorter?

    From 8 columns with 10 rows I need to know if data had been put in or not, code them as '1'; and then need the number of cells that have data put in. I managed to make it work this way, by using the formula below. But I wonder if I can do this more efficient/shorter....

    =SUM(IF(AND(B4>0);"1";"0");(IF(AND(B5>0);"1";"0"));(IF(AND(B6>0);"1";"0"));(IF(AND(B7>0);"1";"0"));(IF(AND(B8>0);"1";"0"));(IF(AND(B9>0);"1";"0"));(IF(AND(B10>0);"1";"0"));(IF(AND(B11>0);"1";"0"));(IF(AND(B12>0);"1";"0"));(IF(AND(B13>0);"1";"0")); (IF(AND(C4>0);"1";"0"));(IF(AND(C5>0);"1";"0"));(IF(AND(C6>0);"1";"0"));(IF(AND(C7>0);"1";"0"));(IF(AND(C8>0);"1";"0"));(IF(AND(C9>0);"1";"0"));(IF(AND(C10>0);"1";"0"));(IF(AND(C11>0);"1";"0"));(IF(AND(C12>0);"1";"0"));(IF(AND(C13>0);"1";"0"));(IF(AND(D4>0);"1";"0"));(IF(AND(D5>0);"1";"0"));(IF(AND(D6>0);"1";"0"));(IF(AND(D7>0);"1";"0"));(IF(AND(D8>0);"1";"0"));(IF(AND(D9>0);"1";"0"));(IF(AND(D10>0);"1";"0"));(IF(AND(D11>0);"1";"0"));(IF(AND(D12>0);"1";"0"));(IF(AND(D13>0);"1";"0"));(IF(AND(E4>0);"1";"0"));(IF(AND(E5>0);"1";"0"));(IF(AND(E6>0);"1";"0"));(IF(AND(E7>0);"1";"0"));(IF(AND(E8>0);"1";"0"));(IF(AND(E9>0);"1";"0"));(IF(AND(E10>0);"1";"0"));(IF(AND(E11>0);"1";"0"));(IF(AND(E12>0);"1";"0"));(IF(AND(E13>0);"1";"0"));(IF(AND(F4>0);"1";"0"));(IF(AND(F5>0);"1";"0"));(IF(AND(F6>0);"1";"0"));(IF(AND(F7>0);"1";"0"));(IF(AND(F8>0);"1";"0"));(IF(AND(F9>0);"1";"0"));(IF(AND(F10>0);"1";"0"));(IF(AND(F11>0);"1";"0"));(IF(AND(F12>0);"1";"0"));(IF(AND(F13>0);"1";"0"));(IF(AND(G4>0);"1";"0"));(IF(AND(G5>0);"1";"0"));(IF(AND(G6>0);"1";"0"));(IF(AND(G7>0);"1";"0"));(IF(AND(G8>0);"1";"0"));(IF(AND(G9>0);"1";"0"));(IF(AND(G10>0);"1";"0"));(IF(AND(G11>0);"1";"0"));(IF(AND(G12>0);"1";"0"));(IF(AND(G13>0);"1";"0"));(IF(AND(H4>0);"1";"0"));(IF(AND(H5>0);"1";"0"));(IF(AND(H6>0);"1";"0"));(IF(AND(H7>0);"1";"0"));(IF(AND(H8>0);"1";"0"));(IF(AND(H9>0);"1";"0"));(IF(AND(H10>0);"1";"0"));(IF(AND(H11>0);"1";"0"));(IF(AND(H12>0);"1";"0"));(IF(AND(H13>0);"1";"0"));(IF(AND(I4>0);"1";"0"));(IF(AND(I5>0);"1";"0"));(IF(AND(I6>0);"1";"0"));(IF(AND(I7>0);"1";"0"));(IF(AND(I8>0);"1";"0"));(IF(AND(I9>0);"1";"0"));(IF(AND(I10>0);"1";"0"));(IF(AND(I11>0);"1";"0"));(IF(AND(I12>0);"1";"0"));(IF(AND(I13>0);"1";"0")))

    Please, find included a test document in which I use this formula. Some data are included.
    Attached Files Attached Files
    Last edited by movinghuman; 05-11-2021 at 10:42 AM. Reason: adapted test document

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How can i make this formula simpler/shorter?

    Hi and welcome to the forum.

    The answer is Yes. However please upload a workbook or a representative cut down copy, anonymised if necessary. It is always easier to advise if we can see your request in its context.

    Show a before and after situation with manually calculated results, explaining which information is data and which is results, and if it's not blindingly obvious how you have arrived at your results some explanatory notes as well.

    To upload a file click the Go Advanced button at the foot of your post, look underneath the post area for the Manage Attachments section and take it from there.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How can i make this formula simpler/shorter?

    This works

    Please Login or Register  to view this content.
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Registered User
    Join Date
    05-11-2021
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO
    Posts
    4

    Re: How can i make this formula simpler/shorter?

    Thanks, but how to deal with the fact that in the original file, the columns involved are not next to each other.... how do I solve that? or should I send another test file in which this is clear?
    And could you explain a little (if possible) about the use of your solution? I am not that advanced in Excel

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How can i make this formula simpler/shorter?

    For the updated file

    =SUMPRODUCT(1*($B$4:$I$13<>0))
    Attached Files Attached Files

  6. #6
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,080

    Re: How can i make this formula simpler/shorter?

    Another option with that test file
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  7. #7
    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,202

    Re: How can i make this formula simpler/shorter?

    or

    =COUNTIF($B4:$I13,"<>")

    and please supply test file with actual format.

  8. #8
    Registered User
    Join Date
    05-11-2021
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO
    Posts
    4

    Re: How can i make this formula simpler/shorter?

    Thanks again for the responses; i created a new test file with the actual format for which the formula is used. Hopefully, this will work better.
    Attached Files Attached Files

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How can i make this formula simpler/shorter?

    As John said, what's wrong with his COUNTIF() function?

    Or indeed an =COUNTA(B4:AK13)

    That said why not future proof your system and simplify your data entry with a normalised two dimensional table thereby allowing easy summary analysis and totalling

    i.e.column labels for

    City
    Trainer Ref
    Other Data Ref (if necessary, entries being Other Data A, Other Data B, ...etc)
    Partner Number
    Days

    and add a new line for every record

  10. #10
    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,202

    Re: How can i make this formula simpler/shorter?

    Try

    =SUMPRODUCT(--(B$4:AG$13<>0)*(LEFT($B$2:$AG$2,6)="Expert"))
    Attached Files Attached Files

  11. #11
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: How can i make this formula simpler/shorter?

    Formula

    =SUMPRODUCT(($B$4:$AK$13>0)*($B$3:$AK$3="# days"))
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    05-11-2021
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO
    Posts
    4

    Re: How can i make this formula simpler/shorter?

    Good morning all, thank you all for your contributions. As I am not an expert, I learn a lot from this forum!!!!

    Your responses provide me with solutions to work with and include good advice for setting up the data file (the entire file, i.e. budget plannings tool for a Grant application, is rather multidimensional).

    =SUMPRODUCT(--(B$4:AG$13<>0)*(LEFT($B$2:$AG$2,6)="Expert"))
    =SUMPRODUCT(($B$4:$AK$13>0)*($B$3:$AK$3="# days"))

    --> both these formulas worked as they skipped the columns in between with other data.

    =COUNTIF($B4:$I13,"<>")
    =COUNTIF($B$4:$AK$13;">=1")
    --> these solutions did not work as they did not skip columns in between with other data.

    So, for me to trial and error and learn, I tried this version: =COUNTIF(($B4:$B13;F4:F13;K4:K13;O4:O13;T4:T13;X4:X13;AC4:AC13;AG4:AG13);">0")
    However, gave me back error; I assume I can only use 1 array definition in this formula? Or should I define the arrays differently?
    Last edited by movinghuman; 05-12-2021 at 03:36 AM. Reason: additional info

  13. #13
    Forum Expert avk's Avatar
    Join Date
    07-12-2007
    Location
    India
    MS-Off Ver
    Microsoft Office 2013
    Posts
    3,223

    Re: How can i make this formula simpler/shorter?

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


    atul


    If my answer (or that of other members) has helped you, please say "Thanks" by clicking the Add Reputation button at the foot of one of their posts.

    Also: if your problem is solved, please take the time to mark your thread as SOLVED by going to the top of your first post, selecting "Thread Tools" and then "Mark 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. rewrite advaced filter code in shorter simpler vba
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-26-2016, 01:47 PM
  2. Make this formula shorter
    By Challebjoern in forum Excel General
    Replies: 16
    Last Post: 10-15-2015, 01:28 AM
  3. How to make this formula shorter
    By PatrikIden in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-04-2015, 06:57 AM
  4. Make a formula shorter
    By PatrikIden in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-03-2014, 01:45 PM
  5. Replies: 0
    Last Post: 09-29-2013, 04:50 AM
  6. [SOLVED] How to make formula shorter ?
    By nur2544 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-19-2012, 02:14 PM
  7. Replies: 3
    Last Post: 05-03-2012, 06:12 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