+ Reply to Thread
Results 1 to 9 of 9

How to copy multiple rows, and change the reference cell

  1. #1
    Registered User
    Join Date
    09-09-2019
    Location
    Gold Coast, Australia
    MS-Off Ver
    365
    Posts
    3

    How to copy multiple rows, and change the reference cell

    Hello Everyone,

    Been searching for a few days, and I cant seem to find an answer that works for me unfortunately.

    I am trying to create an accounting sheet that will combine data for me.

    I have cells for all the data, then I have a column of cells that I need the data sorted in a specific manner. I then need to replicate this 250 times, and I dont really want to manually change the reference cell value 1500 times (6 rows of data x 250) ... lol


    The forumula I have for the first 6 rows is:

    Please Login or Register  to view this content.
    What I need to do is replicate this 249 more times (all 6 rows), but I need to change the reference cell value up by one on each replication. So basically, the next 6 lines needs to be:

    Please Login or Register  to view this content.

    Then the next 6 rows:

    Please Login or Register  to view this content.


    Rinse and repeat until I have replicated all 6 rows 250 times in total.


    These all need to be one after another all in the same column.


    Higlighting all 6 rows, and dragging down changes the reference cell value, but changes it by 5, not 1 (so ="D"&A3 changes to ="D"&A8, and not ="D"&A4, for example).


    Any help anyone can offer would be greatly appreciated, as I really dont want to sit there and manually edit the formulas 1500 times ... hehe.


    Many thanks in advance for any help anyone can offer.

    Rick
    Last edited by Doc.Blade; 09-09-2019 at 07:42 AM.

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,082

    Re: How to copy multiple rows, and change the reference cell

    This should work
    You'll need to copy it down until you get to the 249 or 250 limit 5*250 = around 750 rows I guess

    NOTE: DO NOT CHANGE THE ORDER OF THE LETTERS - THEY ARE CORRECT (even though the order is different to the order you stated - this is because LOOKUP needs things in alphabetical/numerical order with 0 first, MOD(...,5) will produce a 0 on every 5th line generated therefore the 0 must be moved to the first LOOKUP value so it works correctly. Consequently the results for a LOOKUP of 0 - M and C - should also be moved to the first resultant value).

    =LOOKUP(MOD(ROWS($1:1),5),{0,1,2,3,4},{"M","D","U","P","T"})&INDIRECT(LOOKUP(MOD(ROWS($1:1),5),{0,1,2,3,4},{"C","A","D","D","B"})&INT((ROWS($1:1)-1)/5)+3)
    Last edited by Special-K; 09-09-2019 at 08:32 AM.
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: How to copy multiple rows, and change the reference cell

    Using VBA.
    Select those 6 cells then run this code:

    Please Login or Register  to view this content.

  4. #4
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: How to copy multiple rows, and change the reference cell

    Hi

    Another way to do that avoiding the use of INDIRECT
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    where A3 indicate the row of start of data.

  5. #5
    Registered User
    Join Date
    09-09-2019
    Location
    Gold Coast, Australia
    MS-Off Ver
    365
    Posts
    3

    Re: How to copy multiple rows, and change the reference cell

    Thank you everyone for your responses.


    The one that I had the best success with (with my limited knowledge of excel), was this one below. It seemed to work brilliantly, many thanks, but the only problem is the formula did not include adding in the ^ on the 6th line. This is very important to be there to separate the transactions. Any help you can offer to fix the formula to add the ^ in would be greatly appreciated.


    Quote Originally Posted by Special-K View Post
    This should work
    You'll need to copy it down until you get to the 249 or 250 limit 5*250 = around 750 rows I guess

    NOTE: DO NOT CHANGE THE ORDER OF THE LETTERS - THEY ARE CORRECT (even though the order is different to the order you stated - this is because LOOKUP needs things in alphabetical/numerical order with 0 first, MOD(...,5) will produce a 0 on every 5th line generated therefore the 0 must be moved to the first LOOKUP value so it works correctly. Consequently the results for a LOOKUP of 0 - M and C - should also be moved to the first resultant value).

    =LOOKUP(MOD(ROWS($1:1),5),{0,1,2,3,4},{"M","D","U","P","T"})&INDIRECT(LOOKUP(MOD(ROWS($1:1),5),{0,1,2,3,4},{"C","A","D","D","B"})&INT((ROWS($1:1)-1)/5)+3)


    Many thanks again,

    Rick

  6. #6
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,028

    Re: How to copy multiple rows, and change the reference cell

    The code in post 3 didn't work for you?

  7. #7
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: How to copy multiple rows, and change the reference cell

    Hi

    I do not see the last row of your sample with the char ^.

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

  8. #8
    Registered User
    Join Date
    09-09-2019
    Location
    Gold Coast, Australia
    MS-Off Ver
    365
    Posts
    3

    Re: How to copy multiple rows, and change the reference cell

    Hello José,

    Many thanks for that. Was a slight typo in the code, but guessed how to fix it and it worked

    This is what worked:

    Please Login or Register  to view this content.

    After the index, had to change it from {1,4,3,2,3,0} to {1,4,4,2,3,0} and all seemed to work fine.

    Many thanks for that, much appreciated.

    Thank you to Special-K and Akuini too, very much appreciate everyone's help

    Rick

  9. #9
    Forum Expert José Augusto's Avatar
    Join Date
    10-29-2014
    Location
    Portugal
    MS-Off Ver
    2013-2016
    Posts
    3,329

    Re: How to copy multiple rows, and change the reference cell

    You are welcome.

    Thanks for the feedback.

+ 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: 1
    Last Post: 03-17-2013, 06:52 AM
  2. VBA to Change Multiple Pivots' Filters According to a Reference Cell
    By a88 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-26-2012, 06:06 PM
  3. [SOLVED] Copy rows containing a cell reference from another document.
    By roblawl in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-21-2012, 05:54 PM
  4. Copy rows containing a cell reference from another document.
    By roblawl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2012, 06:36 AM
  5. Excel 2007 : copy formula and cell reference does not change
    By MaryKMathias in forum Excel General
    Replies: 2
    Last Post: 12-20-2011, 03:45 AM
  6. Copy selected cells, then change to absolute cell reference
    By Carlsbergen in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-29-2009, 03:15 AM
  7. Replies: 2
    Last Post: 05-26-2009, 05:55 PM
  8. Replies: 2
    Last Post: 06-14-2006, 02:05 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