+ Reply to Thread
Results 1 to 6 of 6

Formula to switch characters around in a cell

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-26-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    128

    Formula to switch characters around in a cell

    This may be simple but what is a formula to switch the contents of cell A1 from "A,1" to "1,A". Essentially, the values before the comma and the values after need to be reversed. The formula needs to be flexible enough to account for strings like "A,12" where there are more than one number/letter on each side of the comma. Help would be greatly appreciated.

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Formula to switch characters around in a cell

    If the values are in A1 going down, put this formula in B1 and copy down:

    =MID(A1, FIND(",", A1)+1, LEN(A1)) & "," & LEFT(A1, FIND(",",A1)-1)
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert
    Join Date
    10-09-2012
    Location
    Dallas, Texas
    MS-Off Ver
    MO 2010 & 2013
    Posts
    3,049

    Re: Formula to switch characters around in a cell

    You can do this a few ways. The easiest will likely be the Data tab -> Text to Columns. Select the column and split the data by the comma. Then you can use a simple concatenate to bring them back together in the other order.

    Another method would be to use the text functions as follows (assuming the data is in call A1, and your formula is in cell b1):

    =RIGHT(A2,LEN(A2)-FIND(",",A2))&","&LEFT(A2,FIND(",",A2)-1)
    Please ensure you mark your thread as Solved once it is. Click here to see how.
    If a post helps, please don't forget to add to our reputation by clicking the star icon in the bottom left-hand corner of a post.

  4. #4
    Forum Contributor
    Join Date
    12-11-2010
    Location
    Indiana, USA
    MS-Off Ver
    Excel 2007
    Posts
    118

    Re: Formula to switch characters around in a cell

    The attached will separate by comma. Great info available here:
    http://www.cpearson.com/Excel/Topic.aspx
    http://www.cpearson.com/Excel/FirstLast.htm
    Attached Files Attached Files

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Formula to switch characters around in a cell

    Or

    =TRIM(RIGHT(SUBSTITUTE(A1,",",REPT(" ",50)),50))&","&TRIM(LEFT(SUBSTITUTE(A1,",",REPT(" ",50)),50))

    Row\Col
    A
    B
    1
    A,1 1,A
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Contributor
    Join Date
    03-26-2014
    Location
    Kentucky
    MS-Off Ver
    Excel 2013
    Posts
    128

    Re: Formula to switch characters around in a cell

    Awesome thank you all that works perfectly!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Option to switch between formula and manually entered value in a cell.
    By lgass in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2014, 04:20 PM
  2. [SOLVED] How to get an AVERAGEIFS formula to not include cell in average, by triggering switch?
    By Carmstrong227 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-19-2013, 01:15 PM
  3. Formula Help- Inserting characters around cell contents
    By dbforum29 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-24-2007, 02:00 PM
  4. limiting characters in a cell by formula
    By Campbell in forum Excel General
    Replies: 2
    Last Post: 07-26-2006, 12:50 PM
  5. [SOLVED] if cell starts with characters formula
    By Norman Kong via OfficeKB.com in forum Excel General
    Replies: 3
    Last Post: 03-24-2005, 07:06 AM

Tags for this Thread

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