View Full Version : Highlight Overlap dates
sathishsusa
03-18-2017, 03:53 AM
Hi,
My previous post may not be explaining clearly to understand the problems. Let me try to give some more clear solution to understand what results I need in my file.
I have a Four Employees. Each employee they want to prepare a leave plan for year 2017. If employees, they want to apply leave Rule is there should not be any overlap date with other employee’s dates.
Now I wish to compare the employees overlap dates by selecting the checkbox. In case any overlapping dates between the employees then I need to highlight the overlap, Column has red color in cells and also, I need the pop up message for overlap dates.
Else
If no any overlap, then pop up messages says like “there is no overlap between selecting employees”.
Finally I need the results to find the overlap dates to highlight so , forums experts if u have any suggestion or idea to solve this problem It will most great help for me. In case u need any more information on this problem to solve. Please let me know
Many sites and Google I searched I could find the correct solution for this but if solved many of them looking similar to find easy method for leave plan for overlap dates.
http://www.excelfox.com/forum/showthread.php/2159-Highlight-and-popup-message-Between-employee-dates-are-overlap-using-(vba)
Pls refer the updated attachment to find for solution.
sathishsusa
03-19-2017, 03:53 PM
trying by below steps can i get the code.. to get solve.
have 4 employees, so i have 4 x DateFrom and 4 x DateTo values to deal with.
step 1: get the input data.
create 2 arrays. eg. myDateFrom(1 to 4) and myDateTo(1 to 4) as date arrays, then read your dates into them
Step 2: Test for overlaps
You need to test each date to see if the start date of any employee is >= to the start date of any other, AND <= the end date of any other employee, and vice versa for the end date. Create a boolean variable to hold the results of the test (eg myFlag)
Step 3: Respond to a failed test
If either the start date or the end date are disqualified (myFlag = false), run a message box and force the selection of a new date. else run any msgbox you wish.
Sub MasterSub()
Call step1
Call step2
End Sub
Sub Step1()
some code goes here
End Sub
Sub Step2()
some code goes here
End Sub
DocAElstein
03-19-2017, 10:24 PM
Hi sathishsusa
This is a very complicated requirement.
You are asking for a complete solution _.... :-(
_... Generally in such a Help Forum as Excel Fox, we try to help you with particular problems, and not do an entire project for you.
But your latest attempt at explaining is good. Nice explanation of your requirement. Well done :) _.. :-) It was a nice clear and easy to follow File which you uploaded :-). Very Good :-)
That made it a lot easier for me
_.. So, I can make a start for you, based only loosely on your proposed solution.
Here is a brief description of a code i habe done for you:
I do not know anything about check boxes. :-(
Rem 2) So I look at TRUE or FALSE value in Range("AS8:AS11")
‘2a) take in checked names data into Array
‘2b) from ‘2a) produce
'2b)(i) complete initial string of overlapping names
and
'2b(ii)
( '2b)(i) add all names to initial string of overlapping names )
and
Build Array of all checked as True names, arrChkTrueEmp()
Rem 3) Main Input data
'3a) I use test data Range "B21:E26" – you will need to change as appropriate.
'3b) use 4 arrays for each data column
Rem 4) Main Outer loop # =====Cnt =========
I take each name form column B data
‘4b) Only if I have a name in the Array of all checked as True names, arrChkTrueEmp(), do I consider the current Name , ( Else do nothing and go on to next name in column B )
____If I have a name in the Array of all checked as True names, Then
________ The Inner Loop ‘ -----CntIn-----------
Rem 5) goes “down” all names in column B.
_________ If a name is also in the Array of all checked as True names, arrChkTrueEmp(), the main Criteria check is done
The criteria is either:_..
_.. The name under consideration in the outer loop has a From date within the From and To dates of name under consideration in second inner loop
________ (arrFrm(Cnt, 1) >= arrFrm(CntIn, 1) And arrFrm(Cnt, 1) <= arrTo(CntIn, 1))
Or
_.. The name under consideration in the outer loop has a To date within the From and To dates of name under consideration in second inner loop
________ (arrTo(Cnt, 1) >= arrFrm(CntIn, 1) And arrTo(Cnt, 1) <= arrTo(CntIn, 1))
_____________ If the criteria is met I put a string of "Overlap" in the Array , arrOvrLpDts(CntIn, 1). This is like your idea ...” …Create a boolean variable to hold the results of the test (eg myFlag)...”
Rem 6) Loop through arrOvrLpDts() Array to add to report string and mark cell
Rem 7) Message Box output of report string
DocAElstein
03-19-2017, 10:26 PM
Results for code described in last Post. ( I have not done everything you wanted )
( Code is here: http://www.excelfox.com/forum/showthread.php/2146-Trying-Blogs-%E0%A4%AC%E0%A5%8D%E0%A4%B2%E0%A5%89%E0%A4%97-%E0%A4%95%E0%A5%8B%E0%A4%B6%E0%A4%BF%E0%A4%B6-%E0%A4%95%E0%A4%B0-%E0%A4%B0%E0%A4%B9%E0%A4%BE-%E0%A4%B9%E0%A5%88-%D8%A8%D9%84%D8%A7%DA%AF%D8%B2-%DA%A9%DB%8C-%DA%A9-160?p=10178#post10178 )
I have not checked the code extensively. I have not done everything you wanted.
I suggest you go through very carefully and try to understand the code and check and / or modify it to suit exactly what you want.
_.......
I did a quick test on your given data.
This was your given data:
Using Excel 2007 32 bit
Row\Col
AS
AT
7
Check Overlap dates
Employee names
8
WAHRemployee01
9
FALSCHemployee02
10
FALSCHemployee03
11
WAHRemployee04
Worksheet: Sheet1
OverLaptestData.JPG http://imgur.com/aHNfebY
1903
Using Excel 2007 32 bit
Row\Col
B
C
D
E
18
Employee Names
From
ToOVER LAP Dates
19
20
21employee01
02. Jan 17
15. Jan 17
22employee03
03. Feb 17
10. Feb 17
23employee04
10. Jan 17
20. Jan 17
24employee04
04. Feb 17
10. Feb 17
25employee02
01. Mrz 17
05. Mrz 17
26employee04
03. Mrz 17
10. Mrz 17
Worksheet: Sheet1
Here is the results after running my code:( Check boxes checked in AS8 and AS11 to make cell value TRUE . Range object "behind" the cells has that entry pseudo as Range object and the True held As a Boolean , ...)
Using Excel 2007 32 bit
Row\Col
B
C
D
E
18
Employee Names
From
ToOVER LAP Dates
19
20
21employee01
02. Jan 17
15. Jan 17
22employee03
03. Feb 17
10. Feb 17
23employee04
10. Jan 17
20. Jan 17
24employee04
04. Feb 17
10. Feb 17
25employee02
01. Mrz 17
05. Mrz 17
26employee04
03. Mrz 17
10. Mrz 17
Worksheet: Sheet1
And Message Box:
MsgBoxOverlaps.JPG http://imgur.com/3XX7PKT
1902
sathishsusa
03-19-2017, 11:01 PM
Hi Docaelstin,
Thanks you so much for your hard work. I know what i ask task is too complicated and I am sorry for taking your time for me. Iam very happy to see your post. I m checking now in my file I will go through it and I will reply to you.
DocAElstein
03-20-2017, 01:19 AM
Hi sathishsusa :-)
Thanks for the feedback.
Try to understand and if / as necessary modify the code yourself as much as possible .
But if you still have problems, or need anything explaining then I will try to help further when I have time
Alan
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
https://www.youtube.com/@alanelston2330 (https://www.youtube.com/@alanelston2330)
https://www.youtube.com/watch?v=yXaYszT11CA&lc=UgxEjo0Di9-9cnl8UnZ4AaABAg.9XYLEH1OwDIA35HNIei0z- (https://www.youtube.com/watch?v=yXaYszT11CA&lc=UgxEjo0Di9-9cnl8UnZ4AaABAg.9XYLEH1OwDIA35HNIei0z-)
https://eileenslounge.com/viewtopic.php?p=316154#p316154 (https://eileenslounge.com/viewtopic.php?p=316154#p316154)
https://www.youtube.com/watch?v=TW3l7PkSPD4&lc=UgwAL_Jrv7yg7WWC8x14AaABAg (https://www.youtube.com/watch?v=TW3l7PkSPD4&lc=UgwAL_Jrv7yg7WWC8x14AaABAg)
https://teylyn.com/2017/03/21/dollarsigns/#comment-191 (https://teylyn.com/2017/03/21/dollarsigns/#comment-191)
https://eileenslounge.com/viewtopic.php?p=317050#p317050 (https://eileenslounge.com/viewtopic.php?p=317050#p317050)
https://eileenslounge.com/viewtopic.php?f=27&t=40953&p=316854#p316854 (https://eileenslounge.com/viewtopic.php?f=27&t=40953&p=316854#p316854)
https://www.eileenslounge.com/viewtopic.php?v=27&t=40953&p=316875#p316875 (https://www.eileenslounge.com/viewtopic.php?v=27&t=40953&p=316875#p316875)
https://eileenslounge.com/viewtopic.php?p=316057#p316057 (https://eileenslounge.com/viewtopic.php?p=316057#p316057)
https://eileenslounge.com/viewtopic.php?p=316705#p316705 (https://eileenslounge.com/viewtopic.php?p=316705#p316705)
https://eileenslounge.com/viewtopic.php?p=316704#p316704 (https://eileenslounge.com/viewtopic.php?p=316704#p316704)
https://eileenslounge.com/viewtopic.php?p=176255#p176255 (https://eileenslounge.com/viewtopic.php?p=176255#p176255)
https://eileenslounge.com/viewtopic.php?f=27&t=40919&p=316597#p316597 (https://eileenslounge.com/viewtopic.php?f=27&t=40919&p=316597#p316597)
https://eileenslounge.com/viewtopic.php?p=316412#p316412 (https://eileenslounge.com/viewtopic.php?p=316412#p316412)
https://eileenslounge.com/viewtopic.php?p=316254#p316254 (https://eileenslounge.com/viewtopic.php?p=316254#p316254)
https://eileenslounge.com/viewtopic.php?p=316280#p316280 (https://eileenslounge.com/viewtopic.php?p=316280#p316280)
https://eileenslounge.com/viewtopic.php?p=315915#p315915 (https://eileenslounge.com/viewtopic.php?p=315915#p315915)
https://eileenslounge.com/viewtopic.php?p=315512#p315512 (https://eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315744#p315744 (https://eileenslounge.com/viewtopic.php?p=315744#p315744)
https://www.eileenslounge.com/viewtopic.php?p=315512#p315512 (https://www.eileenslounge.com/viewtopic.php?p=315512#p315512)
https://eileenslounge.com/viewtopic.php?p=315680#p315680 (https://eileenslounge.com/viewtopic.php?p=315680#p315680)
https://eileenslounge.com/viewtopic.php?p=315743#p315743 (https://eileenslounge.com/viewtopic.php?p=315743#p315743)
https://www.eileenslounge.com/viewtopic.php?p=315326#p315326 (https://www.eileenslounge.com/viewtopic.php?p=315326#p315326)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40752 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40752)
https://eileenslounge.com/viewtopic.php?p=314950#p314950 (https://eileenslounge.com/viewtopic.php?p=314950#p314950)
https://www.eileenslounge.com/viewtopic.php?p=314940#p314940 (https://www.eileenslounge.com/viewtopic.php?p=314940#p314940)
https://www.eileenslounge.com/viewtopic.php?p=314926#p314926 (https://www.eileenslounge.com/viewtopic.php?p=314926#p314926)
https://www.eileenslounge.com/viewtopic.php?p=314920#p314920 (https://www.eileenslounge.com/viewtopic.php?p=314920#p314920)
https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837 (https://www.eileenslounge.com/viewtopic.php?f=30&t=40533&p=314837#p314837)
https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA (https://www.youtube.com/channel/UCnxwq2aGJRbjOo_MO54oaHA)
sathishsusa
03-20-2017, 08:56 AM
Thanks Doc i will do it what you said perfect awesome i will closed the thread.%D
DocAElstein
03-20-2017, 01:40 PM
Hi sathishsusa
i will closed the thread.%D
I think you probably mean “Mark Thread as SOLVED”
But
There is no facility to mark threads as solved at ExcelFox
Threads are not marked as solved at ExcelFox
There is no need for you to take any action in that respect. – You do not need to take any such action when a Thread is solved.
You do not need to do anything
Alan :)
Edit
P.s.
Thanks for the Rep and nice Rep Comments :-) ( By the way, Rep Comments can only be seen by those reciving them - No one else can see them. They are similar to a Private Message. )
sathishsusa
03-20-2017, 02:20 PM
Thanks alan
DocAElstein
03-20-2017, 02:21 PM
Thanks alan
You is welcome
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.