+ Reply to Thread
Results 1 to 5 of 5

A Macro with Message Box to rearrange text in a cell

  1. #1
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Thumbs up A Macro with Message Box to rearrange text in a cell

    Hi Guys

    I would like to know if there is a quick Macro I could use to rearrange text in a cell.

    For example our organisation list all the departments in an unconsistant way and it makes finding the departments hard using A-Z.

    For example some department will say "Department of ...", "Dept of ...", Division of ..." or "Div of ...". (Obviously excluding the quotes).

    What I wanted to know is this. If you highlight the range you wish to work with, could you use a message box to ask you what text you wish to edit and then automatically search the range and make the changes.

    For example search for "Dept of " (note I would need to keep the space after of otherwise I would have leading spaces) so that "Dept of ABC" becomes: "ABC, Dept of" and say "Division of XYZ" becomes "XYZ, Division of"

    I would really appreciate the help of a VBA guru to assist me here as this would help me out greatly when search for departments in my drop down list.

    Thanks in advance for any help offered.
    Last edited by Zyphon; 05-14-2009 at 02:45 AM. Reason: Forgot brackets in some text
    Best Regards.

    Michael
    -----------------------------------
    Windows Vista, Microsoft Office 2007

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: A Macro with Message Box to rearrange text in a cell

    Ctrl -> F on the worksheet will display the find & replace option
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Re: A Macro with Message Box to rearrange text in a cell

    Quote Originally Posted by royUK View Post
    Ctrl -> F on the worksheet will display the find & replace option
    Lol, yes I could use that the Ctrl F function, This would be fine for removing the "Dept of " etc, however I am confused as to how I could get that function to transpose the cell to move said "Dept of " from the beginning of the cell to the end of the cell so that we get the department name first followed by: ", Dept of".

    There are over 700 departments so to manually use the CTRL-F function would be a painful excercise. If I were to use CTRL-F and used say: Find what: "Dept of ABC", Replace with: "ABC, Dept of" and did this individually I would take an age.

    I was hoping a Macro would speed up the process.
    Last edited by Zyphon; 05-13-2009 at 04:20 AM. Reason: Adding more info.

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: A Macro with Message Box to rearrange text in a cell

    Perhaps something along the lines of:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-30-2007
    Location
    London, UK
    MS-Off Ver
    Microsoft Office 2007
    Posts
    317

    Thumbs up Re: A Macro with Message Box to rearrange text in a cell

    Hi DonkeyOte

    Thank you so much for this piece of code it has worked perfectly and did exactly what I wanted. Thanks for your help, you are a genius.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1