+ Reply to Thread
Results 1 to 6 of 6

Insert additional rows into data at specific points

  1. #1
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Insert additional rows into data at specific points

    I have a series of lines described by coordinates. Each row has a point number and x and y coordinates. I want to be able to insert 2 rows between each line - the first one should be blank and the next one should say "pline". Then I paste this into AutoCAD which plots all of the lines at once. Currently I do this ad hoc with VBA but sometimes it takes a little while and it feels like a formula option would be better. I can't seem to figure out how to make it work. Any suggestions? If the answer is that VBA is the best way, I'll continue to use that.

    I've attached an example with 3 short lines. My real data can have a few thousand lines (current file around 5000) with around 100 points each (but variable), so speed could be an issue with a complex solution.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Insert additional rows into data at specific points

    'Nick: try

    Please Login or Register  to view this content.
    6000+ rows in test
    Attached Files Attached Files
    Last edited by JohnTopley; 08-11-2022 at 08:25 AM.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  3. #3
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Insert additional rows into data at specific points

    Hi John,

    I have been using the below. What I was hoping for was a formula solution. In part because I have to do this lots of times and manually filter data to extract each time. If the solution was a formula then it could all be built in more easily.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Insert additional rows into data at specific points

    Please try at G2

    =LET(z,A4:C15,r,ROWS(z),p,INDEX(z,,3),n,COUNTIFS(p,1),c,INDEX(z,,1)&","&INDEX(z,,2),y,SCAN(0,p,LAMBDA(c,v,c+(v=1))),s,SEQUENCE(r+n*2),SORTBY(IFS(s>r+n,"pline",s>r,"",1,c),IF(s>r,MOD(s-r-1,n)+1,y),,IFS(s>r+n,0,s>r,-1,1,p),))
    Attached Files Attached Files

  5. #5
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Insert additional rows into data at specific points

    @Nick, Sorry - my mis-understanding but the cavalry (Bo_Ry) have stepped in!! (and I don't have 365).

    Not sure why a formula makes this easier (no button to press!!) but I don't obviously know the context in which this is done

  6. #6
    Valued Forum Contributor
    Join Date
    07-23-2013
    Location
    London, England
    MS-Off Ver
    Office 365
    Posts
    988

    Re: Insert additional rows into data at specific points

    Thanks both. Bo that works great, thank you.

    With my real data I am using FILTER with various criteria (that the user can edit) to pull certain lines from a large dataset. This caused your formula to break, but I was able to isolate it to the COUNTIFS function in the variable n, so I changed this to be SUM(IF(p=1,1,0)) instead which worked. The final version is in the form:

    =LET(z,FILTER(CHOOSE({1,2,3},A4:A15,B4:B15,C4:C15),C4:C15>=1),r,ROWS(z),p,INDEX(z,,3),n,SUM(IF(p=1,1,0)),c,INDEX(z,,1)&","&INDEX(z,,2),y,SCAN(0,p,LAMBDA(c,v,c+(v=1))),s,SEQUENCE(r+n*2),SORTBY(IFS(s>r+n,"pline",s>r,"",1,c),IF(s>r,MOD(s-r-1,n)+1,y),,IFS(s>r+n,0,s>r,-1,1,p),))

    (there will be various FILTER criteria, this example just includes everything)

+ 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] Insert Data in Rows to Specific Column
    By zrs in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-25-2019, 10:54 AM
  2. Replies: 0
    Last Post: 08-20-2017, 01:23 AM
  3. Insert additional rows on condition
    By etaver87 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-09-2016, 08:35 AM
  4. Insert additional check boxes (ActiveX) to worksheet if more rows of data are added
    By Andrewstupendo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-30-2016, 05:49 PM
  5. [SOLVED] Macro to insert specific number of rows, populate rows with data above except date
    By Melissa Camp in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 10-08-2015, 03:59 PM
  6. Copy/insert additional data entry rows
    By CLEE7093 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-25-2012, 08:57 AM
  7. insert blank rows indicated at specific points
    By JohnnyBGood in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-18-2009, 07:10 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