• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Sick leave periods in one cell|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Sick leave periods in one cell|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumGeneral Excel Questions & Answe…Sick leave periods in one cell
sp_PrintTopic sp_TopicIcon
Sick leave periods in one cell
Avatar
Ivica Cvetkovski

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 25, 2023
sp_UserOfflineSmall Offline
1
March 25, 2023 - 7:02 am
sp_Permalink sp_Print

Hello everyone
I want to find and have in one cell the periods that a person used sick leave (for record purposes) in the month (see the example below). I've tried to find something online, but haven't succeeded. I need it to be in one cell due to report reasons at the end of the month (among other things).
By the way, I need it for excel 2010 (even though the example is in excel 2019).

For example:
A1 to AE1 dates from Jan 1 to Jan 31
Cells D2, E2, F2, N2, O2, P2, Q2, W2, X2, Y2, and Z2 have the letter S, which indicates the day person was on sick leave.
I need cell AF2 to have the following
Jan 4-Jan 6, Jan 14-Jan17, Jan 23-Jan 26.

Avatar
Janset Beyaz

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
February 25, 2023
sp_UserOfflineSmall Offline
2
March 26, 2023 - 2:57 am
sp_Permalink sp_Print

Hi,

I can't see the attached document. If i'm not misinterpreting

 

A1 to AE1 dates from Jan 1 to Jan 31 (31 dates)

However, for February 2023, the dates are from 1 to 28 and are in the range of A1 : AB1.
In this case, assuming AC1 : AE1 = "" or Empty Cells

Please try (in cell AF2)

=SUMPRODUCT(($A$1:$AE$1<>"")*($A2:$AE2="S"))
 
Avatar
Ivica Cvetkovski

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 25, 2023
sp_UserOfflineSmall Offline
3
March 27, 2023 - 3:16 am
sp_Permalink sp_Print sp_EditHistory

Hello Janset Beyaz

Thanks for the reply. And yes, you are right, if it's February, then AC1:AE1 would be empty. 

I don't know why you can't see the attached document (trying again), but your formula is given the number of sick days. What I need is the periods of sick leave (dates from ... to..., or I need cell AF2 to have the following: Jan 4-Jan 6, Jan Jan 14-Jan17, Jan 23-Jan 26). 

Avatar
Hans Hallebeek
the Netherlands
Member
Members
Level 0
Forum Posts: 116
Member Since:
October 17, 2018
sp_UserOfflineSmall Offline
4
March 27, 2023 - 4:04 pm
sp_Permalink sp_Print

Well, now that you actually attached the file it's there.

But, do you want to do this with formulas or macros?

Avatar
Ivica Cvetkovski

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 25, 2023
sp_UserOfflineSmall Offline
5
March 27, 2023 - 9:38 pm
sp_Permalink sp_Print

Well, I would like it with formula.

Avatar
Janset Beyaz

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
February 25, 2023
sp_UserOfflineSmall Offline
6
March 28, 2023 - 7:42 am
sp_Permalink sp_Print

Hi,

If your Excel version is Excel365 and you have DROP, MAP, LAMBDA, HSTACK (in addition to these, REDUCE and VSTACK for auto spill in the range) functions, write the following formula in cell AF2 and try. (If you don't have these functions we have to wait for Hans Hallebeck's solution)

=LET(f,FILTER($A$1:$AE$1,($A$1:$AE$1<>"")*(A2:AE2="S")),a,HSTACK(-1,f,-1),b,COLUMNS(a),c,SEQUENCE(,b-2,2),IFERROR(TEXTJOIN(", ",,MAP(c,LAMBDA(x,IF(INDEX(a,x-1)+1=INDEX(a,x),"",LET(k,MATCH(0,--(DROP(a,,x)=SEQUENCE(,b-x,INDEX(a,1,x)+1)),0)-1,TEXT(INDEX(a,x),"mmm dd")&IF(k=0,"","-"&TEXT(INDEX(a,x)+k,"mmm dd"))))))),""))

Moreover, suppose you have data in the range A2 : AE9. Copy the above formula down to AF9..

If you want auto spill in the range with formula in single cell, first delete the range AF2:AF9 and

formula in cell AF2 and try..

=LET(rng,A2:AE9,d,A1:AE1,s,SEQUENCE(ROWS(rng)),DROP(REDUCE(0,s,LAMBDA(x,y,VSTACK(x,LET(f,FILTER(d,(d<>"")*(INDEX(rng,y,0)="S")),a,HSTACK(-1,f,-1),b,COLUMNS(a),c,SEQUENCE(,b-2,2),IFERROR(TEXTJOIN(", ",,MAP(c,LAMBDA(q,IF(INDEX(a,q-1)+1=INDEX(a,q),"",LET(k,MATCH(0,--(DROP(a,,q)=SEQUENCE(,b-q,INDEX(a,1,q)+1)),0)-1,TEXT(INDEX(a,q),"mmm dd")&IF(k=0,"","-"&TEXT(INDEX(a,q)+k,"mmm dd"))))))),""))))),1))

Avatar
Ivica Cvetkovski

Active Member
Members
Level 0
Forum Posts: 5
Member Since:
March 25, 2023
sp_UserOfflineSmall Offline
7
March 28, 2023 - 4:38 pm
sp_Permalink sp_Print

Janset Beyaz

Thanks for the reply, but unfortunately I don't have that version of excel. 

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Kathleen Silva
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 215
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Ngoc Qui Nguyen
Clement Mansfield
Rose .
Bindu Menon
Baruch Zemer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6352
Posts: 27779

 

Member Stats:
Guest Posters: 49
Members: 32319
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.