+ Reply to Thread
Results 1 to 7 of 7

How to copy and fill a text consecutively in coloumn to "X" number of times provided

  1. #1
    Forum Contributor
    Join Date
    10-08-2013
    Location
    Chennai, INDIA
    MS-Off Ver
    Excel 2010
    Posts
    157

    Question How to copy and fill a text consecutively in coloumn to "X" number of times provided

    Hi,

    My objective is to fill names in a column consecutively to "X" number of times, Example: if i give John 5 times and Woody 6 times....
    Macro should fill john 5 times and consecutively it has to fill Woody 6 times in vertical order in column.

    Name and "X" number will change daily..

    I have explained my need in the sample excel i attached, If anything is not clear please come back....

    Thanks and cheers friends.
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,705

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    See attached file for a formula-based solution.

    Put zero in H6 and this formula in H7:

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


    then copy down to the bottom of your data to give a cumulative count of the names (shown in blue). Then put this formula in A4:

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


    and this one in B4:

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


    then copy both of these down as far as you think you need them.

    Hope this helps.

    Pete
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    10-08-2013
    Location
    Chennai, INDIA
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    Hi Pete,

    Thanks for your simple and clear explanation of solution to my query.

    i ask you a favor, could you please explain what does this formula doing, actually how it is working? i know the purpose of IF, Match, Index functions, but in this how its working please explain?

    =IF(ROWS($1:1)>MAX($H:$H),"",INDEX(E:E,MATCH(ROWS($1:1)-1,$H:$H)+1))

    Thanks Pete...

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    Try the attached code
    Attached Files Attached Files
    Last edited by AB33; 10-09-2013 at 05:00 AM.

  5. #5
    Forum Contributor
    Join Date
    10-08-2013
    Location
    Chennai, INDIA
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    Hi AB33 & Pete,

    I tried the formulas given and its working fine, i forgot to mention this in my previous reply....Thanks...

    Request your explanation for me for the functions given...

    Great appreciation and 1000 thanks to Excel forum and to you guys.. really a great work...
    Bala

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,705

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    The term ROWS($1:1) returns 1 in the first cell it is in, but when the formula is copied down that term becomes ROWS($1:2), then ROWS($1:3), then ROWS($1:4) etc. on successive rows, which return the values 2, 3, 4 and so on, so that allows us to set up an incremental counter within the formula. Clearly, we don't want to return any data beyond the number of repeats that we have, so the first part of the formula ensures this, returning a blank "" if we have copied the formula too far for our needs.

    The MATCH part of the formula is determining which row we should get data from by comparing the counter with the cumulative values in column H - this ensures that we will get 5 successive values pointing to row 7, before getting 5 successive values pointing to row 8, and so on. INDEX just retrieves the data in column E on the row pointed to by the MATCH function.

    Hope this helps.

    Pete

    EDIT: if this has solved your problem please mark the thread as Solved (use Thread Tools just above your first post). Also, click on the "star" icon in the bottom left corner of any post that has helped you so you can pass thanks on more directly to any poster that has helped (not only in this thread).
    Last edited by Pete_UK; 10-09-2013 at 05:12 AM.

  7. #7
    Forum Contributor
    Join Date
    10-08-2013
    Location
    Chennai, INDIA
    MS-Off Ver
    Excel 2010
    Posts
    157

    Re: How to copy and fill a text consecutively in coloumn to "X" number of times provided

    Thanks Pete, Understood fine....

+ 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. Replies: 3
    Last Post: 09-15-2015, 03:00 AM
  2. How can i copy value from "HTMLText"(EMBED("Forms.HTML:Text","")),using Macro
    By andrewyang in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-18-2010, 12:47 AM
  3. Copy a table data "x" number of times to another sheet
    By rkayasth in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 10-20-2009, 04:02 AM
  4. [SOLVED] Re: macro for converting number stored as "text" (or preceeded with ') to "number" formatting
    By markx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2006, 07:14 AM
  5. [SOLVED] macro for converting number stored as "text" (or preceeded with ') to "number" formatting
    By markx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2006, 10:20 AM

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