Segregation of Dates based on DOW (Numeric)

shansakhi

Active Member
Joined
Apr 5, 2008
Messages
276
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hello,

Not sure to fully understand your question ...

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

HTH
 
Upvote 0
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
 
Upvote 0
Hello again,

With your set-up .... when you say ' segregate ' ... do you mean transpose ...???
 
Upvote 0
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:
Upvote 0
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
 
Upvote 0
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]
 
Upvote 0
You're welcome, glad to help, & thanks for the feedback.:)
 
Upvote 0
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>
 
Upvote 0

Forum statistics

Threads
1,213,561
Messages
6,114,312
Members
448,564
Latest member
ED38

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top