+ Reply to Thread
Results 1 to 15 of 15

How to insert items in column A into a range of cells and copying the range

  1. #1
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    How to insert items in column A into a range of cells and copying the range

    Hi guys,

    I have this relatively simple problem, but I have yet to find a solution to this problem.

    What I want to do is this:

    I have a range of strings in column A for simplicity lets say like this:

    Udklip.JPG

    I create a combined string based of different cells where one one of the cell in Column D references the value from column A - see here:

    Udklip2.JPG

    Udklip3.JPG

    Now I want to copy the following and insert right below the grey area:

    Udklip4.JPG

    But as you can see it does not reference the next item in column A, which is "Oranges" but rather it jumps 3 indeces, since this is how much A1 is moved.

    How can I achieve this?

  2. #2
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to insert items in column A into a range of cells and copying the range

    What do you want in the 2nd and 3rd rows? Do you always it to increment by one row every 4th row?

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? Please don't attach a picture of one (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to insert items in column A into a range of cells and copying the range

    Paste this in D2, copy D2:D5 (3 rows), then select destination cells (multiples of 3):
    Please Login or Register  to view this content.
    References:
    $A$1:$A$4 = lookup_range
    ROW(D$2) = first cell of copied section
    /3 = number of rows copied
    Last edited by leelnich; 02-06-2018 at 05:34 AM.
    Clicking the Add Reputation star below helpful posts is a great way to show your appreciation.
    Please mark your threads as SOLVED upon conclusion (Thread Tools above Post # 1). - Lee

  4. #4
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    I want my list of values in column A to vary i.e. if I have 100 values or 4 values it should not matter for my copying, it should always jump one down!

    I have attached my actual project.

    So the following shows what I want:

    Udklip.JPG

    But this is what actually happens when I copy it:

    Udklip2.JPG
    Attached Files Attached Files

  5. #5
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to insert items in column A into a range of cells and copying the range

    Paste this in J6 and copy down. Number will change each time first line repeats:
    Please Login or Register  to view this content.
    ...and this in L6 (copied sectionally):
    Please Login or Register  to view this content.
    Last edited by leelnich; 02-06-2018 at 05:54 AM.

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to insert items in column A into a range of cells and copying the range

    In L6:

    =OFFSET($B$6,INT((ROWS(L$6:L6)-1)/26),,,)

    in L25:

    =OFFSET($B$6,INT((ROWS(L$25:L25)-1)/26),,,)

    and copy down as previously. being in DK, you will probably need ; and not , in the formulae

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to insert items in column A into a range of cells and copying the range

    Nice one Glenn. Could you simplify it?
    Please Login or Register  to view this content.
    ...since Excel automatically truncates fractions in range references.
    Also, no need to change L25:
    Please Login or Register  to view this content.
    ...works.

  8. #8
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    This worked for me. I made a column next to my range where I gave each instance a number 1..2..3..4 etc. Then I changed the /3 part with /max(range) and this did the trick for me.

  9. #9
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    Quote Originally Posted by leelnich View Post
    Paste this in D2, copy D2:D5 (3 rows), then select destination cells (multiples of 3):
    Please Login or Register  to view this content.
    References:
    $A$1:$A$4 = lookup_range
    ROW(D$2) = first cell of copied section
    /3 = number of rows copied
    This worked for me. I made a column next to my range where I gave each instance a number 1..2..3..4 etc. Then I changed the /3 part with /max(range) and this did the trick for me.

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to insert items in column A into a range of cells and copying the range

    Excellent, glad we could help! If that concludes your thread, please mark it as SOLVED (Thread Tools, up top). And since you're new...
    Clicking the Add Reputation star below helpful posts is a nice way to show appreciation to those who contributed. Regards - Lee

  11. #11
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    Quote Originally Posted by leelnich View Post
    Excellent, glad we could help! If that concludes your thread, please mark it as SOLVED (Thread Tools, up top). And since you're new...
    Clicking the Add Reputation star below helpful posts is a nice way to show appreciation to those who contributed. Regards - Lee
    Done and done.

    Thanks for the quick responses. Really appreciate it!

  12. #12
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    Well now I tried a similar setup but it is not working.

    I have attached a sample file.

    It seems now I get a duplicate each time i copy down I dont understand why.

    problem.JPG
    Attached Files Attached Files

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to insert items in column A into a range of cells and copying the range

    Shouldn't it be:

    =INDEX($B$5:$B$13,1+(ROW()-ROW(L$5))/4)

    personal preference.... I prefer this:

    =INDEX($B$5:$B$13,1+INT((ROWS($1:1)-1)/4))

  14. #14
    Registered User
    Join Date
    02-06-2018
    Location
    Copenhagen, Denmark
    MS-Off Ver
    2016
    Posts
    29

    Re: How to insert items in column A into a range of cells and copying the range

    Quote Originally Posted by Glenn Kennedy View Post
    Shouldn't it be:

    =INDEX($B$5:$B$13,1+(ROW()-ROW(L$5))/4)

    personal preference.... I prefer this:

    =INDEX($B$5:$B$13,1+INT((ROWS($1:1)-1)/4))
    Ah yes thank you. I had not fully understood the formula from the beginning.

  15. #15
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to insert items in column A into a range of cells and copying the range

    Quote Originally Posted by Glenn Kennedy View Post
    Shouldn't it be:

    =INDEX($B$5:$B$13,1+(ROW()-ROW(L$5))/4)

    personal preference.... I prefer this:

    =INDEX($B$5:$B$13,1+INT((ROWS($1:1)-1)/4))
    Glenn, do you mean ROWS($5:5)? $1:1 happened to align with the modulus in this case, but introduces an error if the first copied cell is eg. L7.
    That being said, your suggested syntax is perhaps a clearer expression of intent than mine, and uses 1 function call instead of 2.

    03:16 Hang on, having a re-think... $1:1 does NOT error with L7 - but I don't know why...
    03:20 Got it- the relative offset is copied with the formula. My bad, I missed that.

    I would say this though, referencing rows outside of the relevant data area is risky. The formula may break if an "extraneous" row is deleted.
    Please see the attached file for a demonstration...
    Attached Files Attached Files
    Last edited by leelnich; 02-06-2018 at 05:10 PM.

+ 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] Adding Items to List box from cell range but skipping items duplicated in another range
    By alteredbeast in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-11-2017, 04:16 AM
  2. [SOLVED] Copying cell C1 and pasting to range of cells in column C
    By tdf2437 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-15-2016, 06:17 AM
  3. Variable range SUM , base range on other column blank cells?
    By stevnb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-20-2012, 10:55 AM
  4. Replies: 3
    Last Post: 06-22-2010, 07:17 PM
  5. Pulling Items from a multiple column Range
    By Grimace in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 05-05-2009, 02:49 AM
  6. [SOLVED] macro for copying a range to a column of cells
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-08-2006, 08:15 PM
  7. [SOLVED] How to count number of items(cells) in range?
    By George Furnell in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-04-2005, 01:55 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