+ Reply to Thread
Results 1 to 9 of 9

Repeat one column number of times there is text in another

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Smile Repeat one column number of times there is text in another

    Hi,
    im formatting some AD-data in excel and my problem is the following. My data is as follows:

    Group 1 Member 1 Member 2
    Group 2 Member 4 Member 5 Member 6
    Group 3 Member 2 Member 4 Member 6


    And the prefered result would be:

    Member 1 Group 1
    Member 2 Group 1
    Member 6 Group 2
    Member 6 Group 3

    In other words it would be just two columns and the member name repeats the amount of time it belongs to groups and of course the group name repeats just as many times.
    Last edited by Mainman; 09-20-2013 at 05:06 AM.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Repeat one column number of times there is text in another

    Hi and welcome to the forum,

    Where have Members 4 & 5 gone in your desired results?

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: Repeat one column number of times there is text in another

    Please try this file.
    Attached Files Attached Files
    Last edited by ramananhrm; 09-20-2013 at 05:20 AM.
    Please click 'Add reputation', if my answer helped you.

  4. #4
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Repeat one column number of times there is text in another

    Or, if you prefer the Members to be listed in order, then, assuming that the data you give is in the range A1:D3, enter these array (important!) formulas:

    For your Members list (enter in cell I1 and copy down as required):

    =IFERROR("Member "&SMALL(IF($B$1:$D$3<>"",--TRIM(SUBSTITUTE($B$1:$D$3,"Member",""))),ROWS($1:1)),"")

    For your Group list (enter in cell J1 and copy down as required):

    =IFERROR(INDEX($A$1:$A$3,SMALL(IF(($B$1:$D$3=I1)*($B$1:$D$3<>""),ROW($B$1:$D$3)-MIN(ROW($B$1:$D$3))+1),COUNTIF($I$1:$I1,I1))),"")

    Regards
    Last edited by XOR LX; 09-20-2013 at 05:36 AM.

  5. #5
    Registered User
    Join Date
    09-20-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Repeat one column number of times there is text in another

    Quote Originally Posted by ramananhrm View Post
    Please try this file.
    This seems to work, but does it work if one group has more then 3 members. I mean how can i expand the data that it uses ? Any help is much appreciated.

  6. #6
    Registered User
    Join Date
    09-20-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Repeat one column number of times there is text in another

    Quote Originally Posted by XOR LX View Post
    Or, if you prefer the Members to be listed in order, then, assuming that the data you give is in the range A1:D3, enter these array (important!) formulas:

    For your Members list (enter in cell I1 and copy down as required):

    =IFERROR("Member "&SMALL(IF($B$1:$D$3<>"",--TRIM(SUBSTITUTE($B$1:$D$3,"Member",""))),ROWS($1:1)),"")

    For your Group list (enter in cell J1 and copy down as required):

    =IFERROR(INDEX($A$1:$A$3,SMALL(IF(($B$1:$D$3=I1)*($B$1:$D$3<>""),ROW($B$1:$D$3)-MIN(ROW($B$1:$D$3))+1),COUNTIF($I$1:$I1,I1))),"")

    Regards
    I tried using this but it gave me an error at the first "" ($B$1:$D$3<>""). Thank you very much for your efforts.

  7. #7
    Registered User
    Join Date
    09-20-2013
    Location
    Finland
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Repeat one column number of times there is text in another

    Sorry double post

  8. #8
    Valued Forum Contributor
    Join Date
    09-15-2011
    Location
    Chennai, India
    MS-Off Ver
    Excel 2010
    Posts
    436

    Re: Repeat one column number of times there is text in another

    Hi Mainman,

    Please modify the range. I will work.

    Rgds
    Attached Files Attached Files

  9. #9
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Repeat one column number of times there is text in another

    "I tried using this but it gave me an error at the first "" ($B$1:$D$3<>"")."

    I believe your version of Excel may use a slightly different format for the quotation mark ". Try replacing those in my formula with the version generated in your Excel.

    Regards

+ 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] Repeat text 3 times down column
    By Kellypeterson in forum Excel General
    Replies: 13
    Last Post: 09-05-2013, 04:33 AM
  2. Repeat a formula a finite number of times in a column
    By alsers in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-05-2013, 11:18 AM
  3. Replies: 1
    Last Post: 04-04-2013, 05:29 PM
  4. Replies: 1
    Last Post: 04-04-2013, 10:53 AM
  5. Repeat a cell value in another column X number of times
    By art1234 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-31-2011, 02:36 PM

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