+ Reply to Thread
Results 1 to 12 of 12

How to rearrange data using functions and formula!?

  1. #1
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2010
    Posts
    69

    How to rearrange data using functions and formula!?

    Hi everyone, I have an excel file where in column A there are data in the format HxLxW and in column B I want get the values in LxWxH format using a formula and/or fucntion. How can I do that.
    Sample file data:
    before.png

    Expected file data:
    after.png

    I've used the text to column option with 'x' as the delimeter to separate the text in three parts and then using D2&"x"&E2&"x"&C2 in column B to get the result but I was hoping for a simple one go solution without macro's or text to column and then add a separate formula to join.

    Is there is single formula solution for this particular case?
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: How to rearrange data using functions and formula!?

    In C2 copied down:

    =MID(A2,FIND("x",A2)+1,20)&"x"&LEFT(A2,FIND("x",A2)-1)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to rearrange data using functions and formula!?

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    or
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor
    Join Date
    04-27-2015
    Location
    Abu Dhabi, U.A.E
    MS-Off Ver
    Office 365 | 2016
    Posts
    696

    Re: How to rearrange data using functions and formula!?

    LEFT(A2,SEARCH("x",A2,1)-1)

    LEFT(MID(SUBSTITUTE(A2,"x","&",2),SEARCH("x",SUBSTITUTE(A2,"x","&",2),1)+1,SEARCH("&",SUBSTITUTE(A2,"x","&",2),1)),SEARCH("&",MID(SUBSTITUTE(A2,"x","&",2),SEARCH("x",SUBSTITUTE(A2,"x","&",2),1)+2,SEARCH("&",SUBSTITUTE(A2,"x","&",2),1)-1)))

    RIGHT(SUBSTITUTE(A2,"x","&",2),LEN(SUBSTITUTE(A2,"x","&",2))-SEARCH("&",SUBSTITUTE(A2,"x","&",2)))
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: How to rearrange data using functions and formula!?

    Shareez - the OP asked for a one-go solution, not a way to split the string into three.

    Your second and third formulae are unnecessarily long.

  6. #6
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2010
    Posts
    69

    Re: How to rearrange data using functions and formula!?

    HI AliGW, can you explain how your formula works?

    Thanks in advance

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: How to rearrange data using functions and formula!?

    Yes. Let's break it down.

    =MID(A2,FIND("x",A2)+1,20)&"x"&LEFT(A2,FIND("x",A2)-1)

    =MID(A2,FIND("x",A2)+1,20)&"x"&LEFT(A2,FIND("x",A2)-1)

    =FIND("x",A2) returns the position of the first "x" in the string - if you add one, you get the starting position of your second dimension and if you subtract one you get the last character in the string that is the first dimension

    =MID(A2,FIND("x",A2)+1,20) ...

    This returns the 20 characters that start at the character after the first "x" in the string.

    ... &"x"& ...

    This concatenates the first formula result with the second (the characters up to the first "x").

    ... LEFT(A2,FIND("x",A2)-1)


    This returns the first dimension in the string.

  8. #8
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2010
    Posts
    69

    Re: How to rearrange data using functions and formula!?

    Whats with the number 20 in the mid function,why did you choose 20 and not any other? can I change that number?

  9. #9
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2010
    Posts
    69

    Re: How to rearrange data using functions and formula!?

    Hi jason.b75, can you explain your approach? The second/shorter version formula....
    Thanks in advance.

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: How to rearrange data using functions and formula!?

    Sure, I've used the MID function to take the middle of the measurement after duplicating it.

    =A2&"x"&A2 gives you 12.3x15.2x13x12.3x15.2x13

    FIND("x",A2)+1 finds the first x in A2, the +1 at the end tells the formula to start 1 character after the "x".

    LEN(A2) counts the number of characters in A2 and takes the same number of characters from the middle of the part that was joined together earlier (the bit in red).

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,410

    Re: How to rearrange data using functions and formula!?

    Quote Originally Posted by 0Cool View Post
    Whats with the number 20 in the mid function,why did you choose 20 and not any other? can I change that number?
    It can be anything that is long enough. Yes, you can change it: change it to 5 and see what happens (hint: 5 will be too small).

  12. #12
    Registered User
    Join Date
    01-11-2019
    Location
    India
    MS-Off Ver
    2010
    Posts
    69

    Re: How to rearrange data using functions and formula!?

    Thank you both AliGW and jason.b75

+ 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. [SOLVED] VB Code or formula to rearrange data
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-04-2017, 07:35 PM
  2. [SOLVED] How do I rearrange columns, pasting a formula and auto filling the formula
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-05-2016, 05:25 PM
  3. Replies: 0
    Last Post: 03-03-2015, 06:20 PM
  4. [SOLVED] Rearrange Data with formula
    By rizmomin in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-13-2014, 09:19 AM
  5. Formula to remove unwanted data & rearrange last name & first name in a cell
    By rbecker69 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-20-2013, 03:12 AM
  6. if with lookup and rearrange in one formula
    By siwelniffoc93 in forum Excel General
    Replies: 1
    Last Post: 02-16-2012, 07:20 AM
  7. [SOLVED] Rearrange a formula
    By Ali Baba in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-05-2005, 10:05 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