Segregation of Dates based on DOW (Numeric)

shansakhi

Board Regular
Joined
Apr 5, 2008
Messages
216
Hello Everybody,
Need your assistance.
Is there a way we can segregates dates based on DOW (Day of week - numeric).
The data can come in any format.
Below sample data for your reference...

RAW DATA (Here DOW numeric = 1-MON,2-TUE, 3-WED,4-THU,5-FRI,6-SAT,7-SUN)

INPUT OUTPUT
Eff DateDis DateDOWDateDOW
28-Dec-1831-Dec-181528-Dec-185
31-Dec-181
13-Dec-1816-Dec-1845713-Dec-184
14-Dec-185
16-Dec-187
5-Dec-186-Dec-18345-Dec-183
6-Dec-184
24-Dec-1831-Dec-18135724-Dec-181
26-Dec-183
28-Dec-185
30-Dec-187
31-Dec-181

<tbody>
</tbody>
Thank you in Advance.

Regards,
Shan
 

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Hello,

Not sure to fully understand your question ...

You can use the weekday function :
Code:
=weekday(yourdate,2)
HTH
 

shansakhi

Board Regular
Joined
Apr 5, 2008
Messages
216
Thank you James. My requirement is not getting a DOW in numeric... but based on these numeric DOW segregate the dates.

As mentioned below I am getting Input in Eff Date and Dis Date and DOW format which I need to segregate to Date and DOW level

INPUT OUTPUT
Eff DateDis DateDOWDateDOW
28-Dec-1831-Dec-181528-Dec-185
31-Dec-181

<tbody>
</tbody>


Regards,
Shantanu
 

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Hello again,

With your set-up .... when you say ' segregate ' ... do you mean transpose ...???
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,379
Office Version
2013
Platform
Windows
Hi, shansakhi
Does your original data look like this? I mean no blank rows between data rows.

Excel 2007 32 bit
A
B
C
1
Eff DateDis DateDOW
2
28-Des-18​
31-Des-18​
15​
3
13-Des-18​
16-Des-18​
457​
4
05-Des-18​
06-Des-18​
34​
5
24-Des-18​
31-Des-18​
1357​
Sheet: Sheet4
 
Last edited:

shansakhi

Board Regular
Joined
Apr 5, 2008
Messages
216
Hello Akuini,
Sorry for late reply. Yes you are correct...which needs to break it down down to single date based on DOW.

Regards,
Shantanu
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,379
Office Version
2013
Platform
Windows
Hello Akuini,
Sorry for late reply. Yes you are correct...which needs to break it down down to single date based on DOW.

Regards,
Shantanu
Ok, try this:

Code:
[FONT=lucida console][COLOR=Royalblue]Sub[/COLOR] a1076113a()
[I][COLOR=seagreen]'https://www.mrexcel.com/forum/excel-questions/1076113-segregation-dates-based-dow-numeric.html[/COLOR][/I]
[COLOR=Royalblue]Dim[/COLOR] i [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR], j [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR], k [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR], q [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Long[/COLOR]
[COLOR=Royalblue]Dim[/COLOR] va [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Variant[/COLOR], vb [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Variant[/COLOR], vc [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Variant[/COLOR]
[COLOR=Royalblue]Dim[/COLOR] stDate [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Date[/COLOR], enDate [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Date[/COLOR], d [COLOR=Royalblue]As[/COLOR] [COLOR=Royalblue]Date[/COLOR]

va = Range([COLOR=brown]"A2:C"[/COLOR] & Cells(Rows.count, [COLOR=brown]"A"[/COLOR]).[COLOR=Royalblue]End[/COLOR](xlUp).Row)
[COLOR=Royalblue]ReDim[/COLOR] vb([COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] UBound(va, [COLOR=crimson]1[/COLOR]) * [COLOR=crimson]10[/COLOR], [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] [COLOR=crimson]2[/COLOR])
[COLOR=Royalblue]ReDim[/COLOR] vc([COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] UBound(va, [COLOR=crimson]1[/COLOR]) * [COLOR=crimson]10[/COLOR], [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] [COLOR=crimson]3[/COLOR])

[COLOR=Royalblue]For[/COLOR] i = [COLOR=crimson]1[/COLOR] [COLOR=Royalblue]To[/COLOR] UBound(va, [COLOR=crimson]1[/COLOR])
    stDate = va(i, [COLOR=crimson]1[/COLOR])
    enDate = va(i, [COLOR=crimson]2[/COLOR])
      [COLOR=Royalblue]For[/COLOR] d = stDate [COLOR=Royalblue]To[/COLOR] enDate
            q = Weekday(d) - [COLOR=crimson]1[/COLOR]
            [COLOR=Royalblue]If[/COLOR] q = [COLOR=crimson]0[/COLOR] [COLOR=Royalblue]Then[/COLOR] q = [COLOR=crimson]7[/COLOR]
                [COLOR=Royalblue]If[/COLOR] q [COLOR=Royalblue]Like[/COLOR] [COLOR=brown]"["[/COLOR] & Trim(va(i, [COLOR=crimson]3[/COLOR])) & [COLOR=brown]"]"[/COLOR] [COLOR=Royalblue]Then[/COLOR]
                    j = j + [COLOR=crimson]1[/COLOR]
                    k = k + [COLOR=crimson]1[/COLOR]
                    vb(j, [COLOR=crimson]1[/COLOR]) = d
                    vb(j, [COLOR=crimson]2[/COLOR]) = q
                [COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]If[/COLOR]
      [COLOR=Royalblue]Next[/COLOR]
        vc(j - k + [COLOR=crimson]1[/COLOR], [COLOR=crimson]1[/COLOR]) = va(i, [COLOR=crimson]1[/COLOR])
        vc(j - k + [COLOR=crimson]1[/COLOR], [COLOR=crimson]2[/COLOR]) = va(i, [COLOR=crimson]2[/COLOR])
        vc(j - k + [COLOR=crimson]1[/COLOR], [COLOR=crimson]3[/COLOR]) = va(i, [COLOR=crimson]3[/COLOR])
        k = [COLOR=crimson]0[/COLOR]
[COLOR=Royalblue]Next[/COLOR]

Range([COLOR=brown]"A2"[/COLOR]).Resize(j, [COLOR=crimson]3[/COLOR]) = vc
Range([COLOR=brown]"D2"[/COLOR]).Resize(j, [COLOR=crimson]2[/COLOR]) = vb

[COLOR=Royalblue]End[/COLOR] [COLOR=Royalblue]Sub[/COLOR][/FONT]
 

Akuini

Well-known Member
Joined
Feb 1, 2016
Messages
2,379
Office Version
2013
Platform
Windows
You're welcome, glad to help, & thanks for the feedback.:)
 

shansakhi

Board Regular
Joined
Apr 5, 2008
Messages
216
Hi,
Need you help.
The code is working fine. Currently its providing output in D and E column.. Is it possible to provide this output end of all used column.
e.g.
In below case with the existing code I getting output in D and E column... I need this Output in L and M column.

Actual Data

A COLUMNB COLUMNC COLUMND COLUMNE COLUMNF COLUMNG COLUMNH COLUMNI COLUMNJ COLUMNK COLUMN
Eff DtDis DtFRQAlnCTCDEP_1Dep_2DEP_3Dep_4DEP_5Dep_6
24-Apr-1928-Apr-1937AL2027:408:557:408:557:408:55
31-Mar-197-Apr-1937AL2027:408:557:408:557:408:55
14-Apr-1914-Apr-197AL2027:408:557:408:557:408:55

<colgroup><col span="10"><col></colgroup><tbody>
</tbody>

Output Data

A COLUMNB COLUMNC COLUMND COLUMNE COLUMNF COLUMNG COLUMNH COLUMNI COLUMNJ COLUMNK COLUMNL COLUMNM COLUMN
Eff DtDis DtFRQAlnCTCDEP_1Dep_2DEP_3Dep_4DEP_5Dep_6Datefreq
24-Apr-1928-Apr-1937AL2027:408:557:408:557:408:5524-Apr-193
28-Apr-197
31-Mar-197-Apr-1937AL2027:408:557:408:557:408:5531-Mar-197
3-Apr-193
7-Apr-197
14-Apr-1914-Apr-197AL2027:408:557:408:557:408:5514-Apr-197

<colgroup><col><col span="2"><col><col span="2"><col span="2"><col><col><col><col><col></colgroup><tbody>
</tbody>




<colgroup><col width="64" span="7" style="width:48pt"></colgroup><tbody>
</tbody>
 

Forum statistics

Threads
1,082,360
Messages
5,364,927
Members
400,815
Latest member
Joaquin Phoenix

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top