+ Reply to Thread
Results 1 to 9 of 9

Insert line and copy data of previous line with certain changes

  1. #1
    Registered User
    Join Date
    11-24-2013
    Location
    Mumbai
    MS-Off Ver
    Office 365
    Posts
    70

    Insert line and copy data of previous line with certain changes

    Hi All,

    Sir I have to insert row after each line with the following process. I have more than 15000 lines to do so.
    1 Insert line after each original line.
    2 Copy previous rows data in the inserted line
    3 Copied line with following changes
    a Column O amount should be reversed.. i.e positive should negative amount and negative should positive amount
    b Assignment cell (column D) should have data of offset acct of column Q of original line
    c Offset acct (column Q) should have account number of Assignment cell of column D of original line

    I have attached test file for your reference. Changes are shown in Yellow color.

    Thanks in advance.

    Regards,
    Vijay
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    06-24-2005
    Location
    excelliot.com
    MS-Off Ver
    2007
    Posts
    325

    Re: Insert line and copy data of previous line with certain changes

    can you show example for 4 rows of data?

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert line and copy data of previous line with certain changes

    Maybe:

    Please Login or Register  to view this content.
    Last edited by JOHN H. DAVIS; 01-21-2016 at 09:54 AM.

  4. #4
    Forum Contributor
    Join Date
    12-05-2015
    Location
    Akron, OH
    MS-Off Ver
    15.0
    Posts
    424

    Re: Insert line and copy data of previous line with certain changes

    Does this help?

    Please Login or Register  to view this content.
    ...remember to change the Sheet name in the code for your actual data.

    Some improvements can likely be made if I know more info. about how the raw data ends. As-is, it will process all data for which there are rows in which column D is nonempty and does not contain the title: "Assignment". Additionally, the above code assumes that column F (reference values) are unique -- or, at least, you will not have two subsequent lines of data with the same reference number which needs to be processed. Thus, if you run the above code, it will modify the Processed Data as well, since it loops over all rows in the used range.

    *Edited to remove If row > 4, which was for my benefit as I debugged.
    Last edited by joe31623; 01-21-2016 at 09:59 AM.
    <---If my answer helped, please click *

  5. #5
    Registered User
    Join Date
    11-24-2013
    Location
    Mumbai
    MS-Off Ver
    Office 365
    Posts
    70

    Re: Insert line and copy data of previous line with certain changes

    Hi John,

    Its great to see result except condition 3 a of my requirement is not meeting i.e. reverse sign for column O amount. If amount is negative should become positive in inserted line and if amount is positive it should become negative in inserted line with negative sign "-"

    Thanks in advance.

    Regards,
    Vijay

  6. #6
    Forum Contributor
    Join Date
    06-24-2005
    Location
    excelliot.com
    MS-Off Ver
    2007
    Posts
    325

    Re: Insert line and copy data of previous line with certain changes

    You can try this..

    Please Login or Register  to view this content.
    Cheers!!

  7. #7
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert line and copy data of previous line with certain changes

    Quote Originally Posted by vijayca View Post
    Hi John,

    Its great to see result except condition 3 a of my requirement is not meeting i.e. reverse sign for column O amount. If amount is negative should become positive in inserted line and if amount is positive it should become negative in inserted line with negative sign "-"

    Thanks in advance.

    Regards,
    Vijay
    Try:

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-24-2013
    Location
    Mumbai
    MS-Off Ver
    Office 365
    Posts
    70

    Re: Insert line and copy data of previous line with certain changes

    Hi John,

    Thanks a lot. It works like magic. Gr8.

    Regards,
    Vijay

  9. #9
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Insert line and copy data of previous line with certain changes

    You're welcome. Glad to help out and thanks for the feedback. Please mark this thread as SOLVED.

+ 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. Hit Tab button to insert new line and preserve previous lines formulas
    By eighch in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-25-2014, 09:14 PM
  2. deleting a line based on data in a previous line
    By El Conquistador in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-30-2013, 09:49 AM
  3. [SOLVED] Where more than 1 line exists in excel transfer - insert line in word report bookmark
    By PippiLaRue in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 03-13-2013, 05:04 AM
  4. [SOLVED] Moving Contents of Line to End of Previous Line in Word 2010 doc
    By staggers47 in forum Word Formatting & General
    Replies: 4
    Last Post: 12-15-2012, 09:17 AM
  5. Replies: 0
    Last Post: 09-26-2012, 11:26 AM
  6. [SOLVED] Comparing two data sets that don't line up on a line to line basis
    By ghan7650 in forum Excel General
    Replies: 10
    Last Post: 05-22-2012, 05:38 PM
  7. copy line to another line when data is recorded in a cell
    By alestra in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-05-2009, 09:47 PM
  8. [SOLVED] Macro problem on, Yellowed line - previous line or next line.
    By Ed in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-29-2005, 07:06 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