• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to flip contents in excel

Hi Folks.

I want to know how to flip contents within the cell of a excel sheet.

For example, Cell A1 contains the following:

Jan 20: Follow up with Gustavo conducted
Jan 25: Meeting with John held, no issues discussed.
Jan 30: Follow up commenced with VP's.


now, I want to flip contents of A1 so that the cell displays the following order of comments:



Jan 30: Follow up commenced with VP's.
Jan 25: Meeting with John held, no issues discussed.
Jan 20: Follow up with Gustavo conducted


Can someone please help me how to acheive this. thank you.


Sid
 
Hi, Siddarth Ananthula!

As a new user you might want to (I'd say should and must) read this, despite you've yet introduced yourself:
http://chandoo.org/forum/forums/new-users-please-start-here.14/

And regarding your issue, this can be done with VBA code (macro) very easily, and with formulas a bit complex or unmanageable depending on the number of lines in the cell. So I'll omit the formulas only solution.

Try putting this code in a standard module and use it in a formula as:
=FeetToTheRoofHeadToTheFloor(A1)
Code:
Option Explicit

Public Function FeetToTheRoofHeadToTheFloor(psText) As String
    ' constants
    ' declarations
    Dim I As Integer, J As Integer, A As String
    ' start
    I = 0
    A = ""
    ' process
    Do While I < Len(psText & vbLf)
        J = InStr(I + 1, psText & vbLf, vbLf)
        A = Mid(psText & vbLf, I + 1, J - I) & A
        I = J
    Loop
    ' end
    FeetToTheRoofHeadToTheFloor = Left(A, Len(A) - 1)
End Function

Just advise if any issue.

Regards!
 
Back
Top