+ Reply to Thread
Results 1 to 4 of 4

VBA To Insert Row When A New Value Is Detected

  1. #1
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    VBA To Insert Row When A New Value Is Detected

    Hi,

    Please see the attached spreadsheet.

    I need a vba code to detect when then numbers in Column C change and to insert a new row upon this change detection.

    So for an example using the attached (Sheet named "Pre VBA"), i need it to detect when the cell value changes from 23 to 5023 and to insert a new row in between them, and again for 5023 to 31 and so on.

    Also in this new row i want it to copy the information up from the row below but only the information in columns C and D.

    So again for an example using the attached (Sheet named "Post VBA"), this is how i want the finished layout after the VBA has been run, noting that Rows 6, 9, 12, 17 and 20 are the new rows which the VBA code has inserted and copied the data into?

    Let me know what you think

    Many Thanks

    Simon
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: VBA To Insert Row When A New Value Is Detected

    I now have this code working fine which inserts the new row when the sequence in Column C changes:

    Please Login or Register  to view this content.
    BUT - i now need to copy the data in Column C & D from the row below into the new row column C & D

    Thanks

    SImon
    Last edited by arlu1201; 02-18-2013 at 06:48 AM.

  3. #3
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: VBA To Insert Row When A New Value Is Detected

    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  4. #4
    Registered User
    Join Date
    02-11-2013
    Location
    Guernsey
    MS-Off Ver
    Excel 2010
    Posts
    80

    Re: VBA To Insert Row When A New Value Is Detected

    Quote Originally Posted by arlu1201 View Post
    Welcome to the forum.

    I have added code tags to your post. As per forum rule 3, you need to use them whenever you put any code in your post. Please add them in future. If you need more information on how to use them, check my signature below this post.

    Sorry, thanks for amending, will remember that for future posts

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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