+ Reply to Thread
Results 1 to 14 of 14

specail case of use of IF function

  1. #1
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    specail case of use of IF function

    Dears,
    My question myght be really very easy but unfortunately I need your help
    In my sheet I have a formula that counts the number of "P" in specific range
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    the point is that I would like to adjust the formula in the following way: first it should check if the column is empty-if yes it should return "0" or empty if "no" formula should start counting "P" values.
    thanks

  2. #2
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specail case of use of IF function

    Try this array formula...

    =IF(AND(PM!$E$3:E4578="");0;COUNTIF(PM!$E$3:E4578;"P"))


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.
    Last edited by AlKey; 07-19-2014 at 08:18 AM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  3. #3
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: specail case of use of IF function

    I will test and let you know. Meanwhile can you please explain to me how CTRL+SHIFT+ENTER changes the ameaning of the formula?

  4. #4
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: specail case of use of IF function

    I don't understand...

    If the column is empty, then certainly the count of "P" within that column would be 0
    0 is the value you want if it's empty right?
    Last edited by Jonmo1; 07-19-2014 at 09:12 AM.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specail case of use of IF function

    CTRL+SHIFT+ENTER is used to activate array functionality. Here is another version that don't require to use CTRL+SHIFT+ENTER


    =IF(COUNTA(PM!$E$3:E4578)=0;0;COUNTIF(PM!$E$3:E4578;"P"))

  6. #6
    Forum Contributor
    Join Date
    08-11-2012
    Location
    bengalur
    MS-Off Ver
    Excel 2003, 2007
    Posts
    152

    Re: specail case of use of IF function

    =IF(COUNTA(PM!$E$3:E4578)=0,0,COUNTIF(PM!$E$3:E4578;"P"))
    As per the AIKey this formula has to work.

  7. #7
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: specail case of use of IF function

    How is the result from that formula any different from the result of the original formula?

  8. #8
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specail case of use of IF function

    @ Jonmo1
    LOL! It is not

  9. #9
    Forum Guru Jonmo1's Avatar
    Join Date
    03-08-2013
    Location
    Bryan, TX
    MS-Off Ver
    Excel 2010
    Posts
    9,763

    Re: specail case of use of IF function

    Now if the intended purpose here is to differentiate between
    A) 0 result because the column is Empty
    or
    B) 0 result when the column is NOT empty, but there are no values that meet the criteria

    Then you need to return something other than 0 when the column is empty.
    Perhaps a text string like "It's Empty" or just the formula blank ""

    =IF(COUNTA(PM!$E$3:E4578)=0;"It's Empty";COUNTIF(PM!$E$3:E4578;"P"))
    or
    =IF(COUNTA(PM!$E$3:E4578)=0;"";COUNTIF(PM!$E$3:E4578;"P"))
    Last edited by Jonmo1; 07-19-2014 at 10:39 AM.

  10. #10
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: specail case of use of IF function

    That formula looks simpler, but does not work because I should have mentioned that in some of the cell in the column there is a formula which makes the cell value empty but counta detects it as not empty. practically for me it should count it as empty.

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specail case of use of IF function

    One more

    =IF(COUNTIF(PM!$E$3:E4578;"?*")=0;"Empty";COUNTIF(PM!$E$3:E4578;"P"))

  12. #12
    Forum Contributor
    Join Date
    01-20-2011
    Location
    liverpool
    MS-Off Ver
    Excel 2016
    Posts
    198

    Re: specail case of use of IF function

    Quote Originally Posted by AlKey View Post
    One more

    =IF(COUNTIF(PM!$E$3:E4578;"?*")=0;"Empty";COUNTIF(PM!$E$3:E4578;"P"))
    That formula works as well.
    could you please let me know how "?*" that works?

  13. #13
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: specail case of use of IF function

    You can try this as well...
    with on ?*

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


    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. Press F2 on that cell and try again.


    Don't forget to click *

  14. #14
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: specail case of use of IF function

    Thank you for the feedback!

    This COUNTIF(PM!$E$3:E4578;"?*") will count if there are any character or spaces in the range present.

    Please mark thread as "Solved" if your issue has been resolved. (Selecting Thread Tools-> Mark thread as Solved).
    Last edited by AlKey; 07-20-2014 at 07:17 AM.

+ 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. Function and CASE
    By malcmail in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2014, 09:19 AM
  2. Need help to change multiple criteria from if function to Case function.
    By indkitty in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-29-2012, 10:42 PM
  3. Help: Using Case Like Function w/ Strings
    By Timer in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-20-2011, 02:10 PM
  4. Case function
    By Rage in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-05-2011, 08:32 AM
  5. Case function
    By Al in forum Excel General
    Replies: 5
    Last Post: 08-23-2005, 04:05 PM

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