Transpose dates in rows to columns

Prakash K

New Member
Joined
Oct 23, 2024
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Dear Experts, I have random dates in E9:H100 (in odd rows like E9,E11,..,G9,G11,... & also some cellsblanks)... I need these dates in ascending order in 7th row from K7 (K7,L7,M7,N7,....) Please help me...
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Try this. Remember to test on a COPY of your Workbook. Paste code into the Sheet code module of the Worksheet that you want to affect.
VBA Code:
Option Explicit

Sub ExtractDates()

Dim sRng As Range, cell As Range, fDates(), i As Integer

Set sRng = Me.Range("E9:H100")

For Each cell In sRng
    If IsDate(cell.Value) Then
        ReDim Preserve fDates(i)
        fDates(i) = cell.Value
        i = i + 1
    End If
Next cell

For i = 0 To UBound(fDates)
    Me.Cells(i + 7, "K") = fDates(i)
Next i

With ActiveWorkbook.Worksheets("Sheet1").Sort
        .SetRange Range("K7:K" & UBound(fDates) + 7)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
 
Upvote 0
Dear Experts, I have random dates in E9:H100 (in odd rows like E9,E11,..,G9,G11,... & also some cellsblanks)... I need these dates in ascending order in 7th row from K7 (K7,L7,M7,N7,....) Please help me...
=LET(d,VSTACK($E$9:$E$100,$F$9:$F$100,$G$9:$G$100,$H$9:$H$100),TRANSPOSE(SORT(FILTER(d,INDEX(d,,1)<>""),1)))
 
Upvote 0
Edit:
VBA Code:
Option Explicit

Sub ExtractDates()

Dim sRng As Range, cell As Range, fDates(), i As Integer

Set sRng = Me.Range("E9:H100")

For Each cell In sRng
    If IsDate(cell.Value) Then
        ReDim Preserve fDates(i)
        fDates(i) = cell.Value
        i = i + 1
    End If
Next cell

For i = 0 To UBound(fDates)
    Me.Cells(i + 7, "K") = fDates(i)
Next i

With Me.Sort
        .SetRange Range("K7:K" & UBound(fDates) + 7)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
 
Upvote 0
#NAME ERROR
Transpose dates in rows to columns.xlsm
EFGHIJKLMNOPQRSTUVWXYZAAABACAD
6
730/01/202403/02/202404/02/202428/02/202408/03/202409/03/202423/03/202402/04/202403/04/202425/04/202416/05/202404/07/202407/07/202421/07/202413/08/202406/12/202420/12/202431/12/2024
8
902/04/2024
10
11
12
13
14
15
16
17
18
19
20
2130/01/2024
22
2303/02/202425/04/2024
24
25
26
27
28
29
30
31
32
33
34
3504/02/202420/12/2024
36
37
38
39
40
41
42
43
44
45
46
4708/03/2024
48
49
50
5103/04/2024
52
53
54
5506/12/2024
56
5709/03/2024
58
59
60
61
62
6316/05/2024
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
7928/02/202404/07/2024
80
8121/07/2024
82
83
84
8523/03/2024
86
8713/08/202431/12/2024
88
89
90
91
92
93
94
95
96
97
98
9907/07/2024
100
101
102
Sheet2
Cell Formulas
RangeFormula
K7:AB7K7=LET(d,VSTACK($E$9:$E$100,$F$9:$F$100,$G$9:$G$100,$H$9:$H$100),TRANSPOSE(SORT(FILTER(d,INDEX(d,,1)<>""),1)))
Dynamic array formulas.
 
Upvote 0
Another possible option
Excel Formula:
=SORT(TOROW(E9:H100,1),,,1)
 
Upvote 0
sir,
Edit:
VBA Code:
Option Explicit

Sub ExtractDates()

Dim sRng As Range, cell As Range, fDates(), i As Integer

Set sRng = Me.Range("E9:H100")

For Each cell In sRng
    If IsDate(cell.Value) Then
        ReDim Preserve fDates(i)
        fDates(i) = cell.Value
        i = i + 1
    End If
Next cell

For i = 0 To UBound(fDates)
    Me.Cells(i + 7, "K") = fDates(i)
Next i

With Me.Sort
        .SetRange Range("K7:K" & UBound(fDates) + 7)
        .Header = xlNo
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With

End Sub
working well... but i need dates in 7th row from K7,L7,M7.... & I NEED UNIQUE DATES ONLY
 
Upvote 0

Forum statistics

Threads
1,223,627
Messages
6,173,425
Members
452,515
Latest member
Alicedonald9

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