shift segment of a rows to next rows

excel_learner_vba

New Member
Joined
Jun 1, 2019
Messages
1
Data looks as below want it as below
May 05 2019 May 05 2019Jun 17 2019Aug 9 2019
a aesg
rs rsadgh
1 1451234
[+1] [+1]
Jun 17 2019
e
a
45
Aug 9 2019
sg
dgh
1234

<colgroup><col><col><col><col><col></colgroup><tbody>
</tbody>


I am just stuck with this. Could you please give me a macro code or some other method to do this? thank you very much!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Hi excel_learner_vba,

Welcome to the MrExcel Forum. This code works with the data you provided above. The only caveat is that you must continue to use the standard 3 letter abbreviation for the names of the months.

Also, this code will delete data that is not recoverable, please test this on a backup copy of your work.

Code:
Sub MoveText()


    Dim arr, pos, mns
    Dim val As String
    Dim lRow As Long, i As Long, c As Long, r As Long


    mns = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
    lRow = Cells(Rows.Count, 1).End(xlUp).Row
    arr = Range("A1:A" & lRow)
    Range("A1:A" & lRow).ClearContents
    For i = LBound(arr) To UBound(arr)
        val = Left(arr(i, 1), 3)
        pos = Application.Match(val, mns, False)
        If Not IsError(pos) Then
            r = 1
            c = c + 1
            Cells(r, c) = arr(i, 1)
            r = r + 1
        Else
            Cells(r, c) = arr(i, 1)
            r = r + 1
        End If
    Next


End Sub

I hope this helps...
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,979
Members
449,276
Latest member
surendra75

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