+ Reply to Thread
Results 1 to 42 of 42

Count additional days

  1. #1
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Count additional days

    Hello everybody
    Before mentioning my question,I'd like to thank all members in this forum.you helped me alot in my questions.
    The question:
    *Column "A" contains rest type for every employee
    *"AK3" contains Rest days scehdule
    *I want to count the number of attendance "refered to as 8" in the rest days of each employees ,in another word additional days
    *I prefer using formula rather than VBA or udf
    *I want the formula to be in column "AI"
    I hope you help me
    Attached Files Attached Files

  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: Count additional days

    Are the column AI values the RESULTS that you expect to see from a formula?
    If so would you explain exactly how you have calculated them. It's not at all clear to me. Is the table in AK3:AS7 at all relevant?
    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 Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    AI shows the expected results.and I also colored the cells.
    Note:Row 3 contains days of the month
    Find the attachment ,I added 2 examples
    I hope you understand me??
    Attached Files Attached Files
    Last edited by leprince2007; 01-05-2017 at 05:55 PM.

  4. #4
    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: Count additional days

    See attached.

    You'd be better advised to mark a helper row above each data set (See D27:AH27) and use a COUNTIFS() formula (K33)
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    You misunderstood me
    These are 2 examples,last row in my data is 15.
    I want the formula to be in column "AI"
    I don't want to count on helper columns.
    Note:
    My original file contains 150 employees
    I hope you help me

  6. #6
    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: Count additional days

    You'd be better advised to extend the AK4:AS7 table to a matrix of 31 columns, one for each day. Then mark the rest day numbers with say an "x" in the appropriate column.

    Then you'll be able to use an array formula to compare the 31 days in C:AG with the 31 days in the appropriate AK:BO row with an array formula. SO if you're reluctant to use helper columns or change the layout like this I don't think I can help.

  7. #7
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    I edited the data as you requested.find the attachment.
    Attached Files Attached Files

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

    Re: Count additional days

    AI4
    Please Login or Register  to view this content.
    TRY THIS AND COPY TOWARDS DOWN
    Samba

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

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

    Re: Count additional days

    OR CAN TRY
    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Quote Originally Posted by nflsales View Post
    AI4
    Please Login or Register  to view this content.
    TRY THIS AND COPY TOWARDS DOWN
    Thank you sir for your help
    1-Sumproduct works but countifs didn't work.can you try to correct it?
    2- can you create a function for my first file??as in my second file I changed the file as I added the 31 days in rest days schedule
    I wish you help me

  11. #11
    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,339

    Re: Count additional days

    COUNTIFS formula produced same result as SUMPRODUCT when I tested it on you file from post #7.

  12. #12
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Can you help me in the file from post1#

  13. #13
    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,339

    Re: Count additional days

    Try

    Example 1

    =SUMPRODUCT(($D$29:$AH$29=8)*($D$28:$AH$28=TRANSPOSE($AK$29:$AR$29)))

    Example 2

    =SUMPRODUCT(($D$37:$AH$37=8)*($D$36:$AH$36=TRANSPOSE($AK$37:$AR$37)))


    Enter both with Ctrl+Shift+Enter

  14. #14
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769
    Quote Originally Posted by JohnTopley View Post
    Try

    Example 1

    =SUMPRODUCT(($D$29:$AH$29=8)*($D$28:$AH$28=TRANSPOSE($AK$29:$AR$29)))

    Example 2

    =SUMPRODUCT(($D$37:$AH$37=8)*($D$36:$AH$36=TRANSPOSE($AK$37:$AR$37)))


    Enter both with Ctrl+Shift+Enter
    Thank you for your reply.After I made some changes to your formula,I solved my question.
    I just have two questions:
    1-this formula counts overtime days.
    Can you get the dates of overtime?
    In this form "06+08+20"
    2-What is the role of Transpose in your formula??
    I hope you help me
    Last edited by leprince2007; 01-06-2017 at 06:07 PM.

  15. #15
    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,339

    Re: Count additional days

    Try

    In AI4

    =SUMPRODUCT(($C4:$AG4=8)*($C$3:$AG$3=TRANSPOSE(INDIRECT($A4))))

    Enter with Ctrl+Shift+Enter

    I create a named range for each "Rest Type" which are referenced via the INDIRECT formula,
    Attached Files Attached Files

  16. #16
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Thank you for your reply.
    I just have two questions:
    1-this formula counts overtime days.
    Can you get the dates of overtime?
    In this form "06+08+20"
    2-What is the role of Transpose in your formula??
    I hope you help me
    Last edited by leprince2007; 01-06-2017 at 06:47 PM.

  17. #17
    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,339

    Re: Count additional days

    I have no idea what "06+08+20" refers to: there are no 06/20 entries in the data other than the date (day) row 3? You will need to post a file with example(s).

    Transpose is required for the SUMPRODUCT to work and treats the data as rows rather than columns and hence scalar values.
    Last edited by JohnTopley; 01-07-2017 at 03:13 AM.

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

    Re: Count additional days

    please attach fresh excel file with expected result with details how you arrived it

  19. #19
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769
    Quote Originally Posted by nflsales View Post
    please attach fresh excel file with expected result with details how you arrived it
    Thank you all for your interest and quick reply
    The formula you have already created to calculate the count of additional days.
    I want now a formula to write the dates of "additional dates" in column AI.
    Find the attachment -column AI
    Attached Files Attached Files

  20. #20
    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,339

    Re: Count additional days

    Please Login or Register  to view this content.
    =add_Dates(indirect(a4))

    See column AK

    NOTE: I have changed days in row 3 to be format "00" so entered as numbers, and same for "Rest Days"

    Avoid using TEXT for numeric data as it often results in problems.
    Attached Files Attached Files

  21. #21
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Thank you sir for your reply.
    1- I don't like UDF because it doesnot recalculate well
    I have a workbook with multiple sheets,when I edit some data in another sheet,and come back to the sheet that contains the UDF ,I found its result gives error and changes.
    Or when I work in another workbook this happens.
    I think this happens because the formula take the range only without its current workbook & sheet.
    Can you make the UDF take the workbook and sheet with range??
    2- or can you use normal formulas??

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

    Re: Count additional days

    AI4
    Please Login or Register  to view this content.
    AJ=
    Please Login or Register  to view this content.
    IT IS BETTER TO USE @JohnTopley VBA Solution
    the above formula is looks like a lengthy and it is limited to 8 dates, you can extend by modifying the formula
    Attached Files Attached Files

  23. #23
    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,339

    Re: Count additional days

    The scope of the named range is WORKBOOK so using the UDF in many sheets is OK BUT ensure there only ONE version of the "Rest Day" table. Placing the table in a separate is a better solution.

    See the attached which has a copy of "Data" ("Data (2)" without the table (still in "DATA")

    Otherwise you are left with a complex formula as per post NFLSALES.
    Attached Files Attached Files

  24. #24
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769
    Thank you Mr nflsales for your reply
    1- can the UDF take workbook&sheet& range?
    2-your formula is very big.see the attached,I sumarized the rest days schedule.can you adjust the formula,I think it will be shorter now?
    Attached Files Attached Files

  25. #25
    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,339

    Re: Count additional days

    Function only works in workbook in which it resides unless you create a PERSONAL.XLSB file and place UDF here.


    https://support.office.com/en-gb/art...0-6e4c3f5ee566

  26. #26
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769
    Quote Originally Posted by JohnTopley View Post
    Function only works in workbook in which it resides unless you create a PERSONAL.XLSB file and place UDF here.


    https://support.office.com/en-gb/art...0-6e4c3f5ee566
    I don't want the formula to get data from another workbook.
    I want it to get the activeworkbook&active sheet

  27. #27
    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,339

    Re: Count additional days

    I want it to get the activeworkbook&active sheet
    .. so you already have that solution.

    You appear not to understand how this works.

  28. #28
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    But your udf lacks dealing with active workbook.Try working in any another workbook and return to my workbook,you will find that your udf return error or "".
    I hope you ubderstand this.

  29. #29
    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,339

    Re: Count additional days

    If the UDF (NOT DATA) was placed in a PERSONAL.XLSB workbook, then the UDF is available to ALL workbooks.

    If you don't want to pursue this route then you will have rely on someone producing a manageable formula.

    Any reason why you have multiple workbooks rather than multiple sheets in one workbook?

  30. #30
    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,339

    Re: Count additional days

    As Siva's formula works, then use that unless you are going have considerably more "Rest Days" than 8.
    Last edited by JohnTopley; 01-07-2017 at 09:15 AM.

  31. #31
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    1-the UDF is placed in one file that doesn't take any data from any file else and has no relation to my file.
    2-Try working in any other file-that has no relation to my file
    3- return to my file,you will find that your udf return error or "".
    I hope you ubderstand this.

  32. #32
    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,339

    Re: Count additional days

    The UDF has be placed in workbook called PERSONAL.XLSB (not any workbook you choose). I know this works because I am running one of your sample workbooks with the UDF removed from it (but in (my) PERSONAL.XLSB).

    I have explained this several times to you.

    And you still did not reply to the question of why many workbooks for (as far as I understand it) the same requirement.

    I cannot help any further: you have been offered 2 solutions - make your choice.
    Last edited by JohnTopley; 01-07-2017 at 03:38 PM.

  33. #33
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    My work requires me to work in multiple files.
    Do You mean that I should open one file only?
    See this link that contains the same problem I have with UDF;
    http://stackoverflow.com/questions/3...hen-not-active
    Last edited by leprince2007; 01-07-2017 at 09:50 AM.

  34. #34
    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,339

    Re: Count additional days

    The problem you referenced is not the one you face.

    If you use the formula solution (or VBA) you will still need to create the named ranges in EACH workbook: having multiple workbooks when you can put many sheets in a single workbook escapes me as it creates much more work maintaining them.

    As for using VBA, I have explained the way to proceed.
    Last edited by JohnTopley; 01-07-2017 at 03:39 PM.

  35. #35
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Please please please please
    it is the same problem in the Link.
    Why you are insisting that I want to use the formula in multiple workbooks??

  36. #36
    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,339

    Re: Count additional days

    It is not the same problem (in my view) : if you want to take it further start a new thread on the VBA macro forum where you will find people with a greater knowledge of VBA than myself. I have it working on multiple workbooks using the approach I suggested.

    I am not insisting anything re the formula: you "requested" a formula solution which has been provided.

    I repeat my comment about having multiple workbooks and the maintenance required to keep them aligned.

  37. #37
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769
    Quote Originally Posted by nflsales View Post
    AI4
    Please Login or Register  to view this content.
    AJ=
    Please Login or Register  to view this content.
    IT IS BETTER TO USE @JohnTopley VBA Solution
    the above formula is looks like a lengthy and it is limited to 8 dates, you can extend by modifying the formula
    Thank you Mr nflsales for your reply
    your formula is very big.see the attached,I sumarized the rest days schedule.can you adjust the formula,I think it will be shorter now?
    Attached Files Attached Files

  38. #38
    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,339

    Re: Count additional days

    I would be most surprised if your new proposal results in a simpler formula as it has to "decode" the text string into the component numbers.

    You'll be happy if I am proved wrong!

  39. #39
    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,339

    Re: Count additional days

    Is the following acceptable using Conditional Formatting:

    CF rule

    =AND(MATCH(DAY(C$3),INDIRECT($A4),0),C4=8)

    Colour RED in attached sample.
    Attached Files Attached Files

  40. #40
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Quote Originally Posted by JohnTopley View Post
    Is the following acceptable using Conditional Formatting:

    CF rule

    =AND(MATCH(DAY(C$3),INDIRECT($A4),0),C4=8)

    Colour RED in attached sample.
    Thank you Mr. JohnTopley for your conditional formatting!!
    But I want to adjust the substitute formula that Mr. nflsales created before as I combined the rest days into one cell.

  41. #41
    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,339

    Re: Count additional days

    I am sure if Siva (Mr Nflsales) could have devised a simpler formula he would have done so, as he is very competent at creating complex formulae.

    As I stated earlier, I cannot see the change you propose making thinks easier.

    IT IS BETTER TO USE @JohnTopley VBA Solution
    the above formula is looks like a lengthy and it is limited to 8 dates, you can extend by modifying the formula
    from Siva

  42. #42
    Forum Contributor
    Join Date
    02-24-2015
    Location
    Egypt
    MS-Off Ver
    Office 365 ProPlus
    Posts
    769

    Re: Count additional days

    Ok thanks I don`t want anything else

+ 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. Trying to create a formula to count days based on 8 hour days
    By meadnl89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-03-2016, 06:41 PM
  2. [SOLVED] Add additional days/weeks/months based on user input
    By pauldaddyadams in forum Excel General
    Replies: 3
    Last Post: 12-09-2015, 01:29 PM
  3. Formula for vacation days earned annualy with additional days at a milestone
    By poTATEohhh in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-29-2015, 08:40 AM
  4. [SOLVED] Count 6 working days (excluding Sunday, Holidays & half days)
    By eve_star1 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-29-2015, 08:00 AM
  5. Sort query on sum of count + additional count
    By TomBP in forum Access Tables & Databases
    Replies: 6
    Last Post: 11-30-2010, 11:43 AM
  6. Calculating time elapsed in days and count days within same range
    By michellem410 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-19-2008, 01:13 PM
  7. [SOLVED] Time calculations and additional 24 hour days
    By Mark G in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-29-2005, 04:45 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