+ Reply to Thread
Results 1 to 6 of 6

Help copy row to new sheet x times depending on cell value.

  1. #1
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Help copy row to new sheet x times depending on cell value.

    Hi Guys,

    Can someone help me please.

    I have a spreadsheet which will have approx 1000 rows of data, the cells in column V will be updated to have a number from 0 - 10.

    So if the cell V6 = 2 copy row V6 twice to sheet2, then if cell V10 = 3 copy row V10 three times to the next available row in sheet2,

    If cells in column V are blank or = 0 do nothing.


    Hope this makes sense.


    Thanks

  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,733

    Re: Help copy row to new sheet x times depending on cell value.

    Are you still using XL2003, as your profile states, or have you upgraded to a later version? This affects some of the functions that we can use.

    Also, how many columns are you using? Is column V the final column?

    Pete

  3. #3
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Help copy row to new sheet x times depending on cell value.

    Hi Pete, Using excel 2010 and column W is the final column.

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

    Re: Help copy row to new sheet x times depending on cell value.

    Okay, put this formula in cell X2 of the first sheet:

    =IF(OR(V2=0,V2=""),"-",MAX(X$1:X1)+1)

    and copy down to the bottom of your data. It allocates a sequential number to those records where the entry in column V is neither blank nor equal to zero.

    Then in the second sheet you can use these formulae in the cells stated:

    X2: =IF(ROWS($1:1)>MAX(Sheet1!X:X),"",MATCH(ROWS($1:1),Sheet1!X:X,0))

    Y2: =IF(X2="","",INDEX(Sheet1!V:V,X2))

    Z2: =IF(Y2="","",Y2+Z1)

    and copy these down until you start to get blanks. You also need to put zero in cell Z1.

    Then in A2 you can have this formula:

    =IF(ROWS($1:1)>MAX($Z:$Z),"",INDEX(Sheet3!A:A,INDEX($X:$X,MATCH(ROWS($1:1)-1,$Z:$Z)+1)))

    Copy this across to W2, and then copy the formulae in A2:W2 down as far as you need to (i.e. until you start to get blanks).

    Hope this helps.

    Pete

    EDIT: please update your profile on UserCP to show the version of Excel that you are using.

  5. #5
    Registered User
    Join Date
    05-14-2014
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Help copy row to new sheet x times depending on cell value.

    Thank you so much Pete, that is really helpful and works a treat !!



    PS Profile update

  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,733

    Re: Help copy row to new sheet x times depending on cell value.

    You're welcome - thanks for feeding back.

    Pete

+ 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] Copy range to other sheet depending on entry in cell
    By RutgerdV in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-17-2016, 06:11 AM
  2. Check cell value in range, depending on condition copy to another Sheet
    By KemalO in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-28-2015, 11:01 AM
  3. [SOLVED] Copy cell from 1 sheet to another sheet depending on what info is displayed in a cell
    By chilli76 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-24-2013, 12:33 PM
  4. copy a cell multiple times depending on cell value starting on a specific cell
    By weritadiojomiel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-17-2013, 05:25 AM
  5. Macro to copy data from one sheet to another depending on name in first cell
    By subtilty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-14-2013, 07:44 AM
  6. Copy cell to another sheet 15 times
    By polomontreal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-08-2011, 11:33 AM
  7. copy sheet a # of times based on cell value
    By nuver in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2005, 03:34 PM

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