+ Reply to Thread
Results 1 to 7 of 7

Need Macro that inserts two rows with data after value changes

  1. #1
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Need Macro that inserts two rows with data after value changes

    Hello All,

    I've been searching around and finding some promising code but nothing that I can seem to get to work with my level of knowledge.
    I started trying to used Gary B's second post in this thread:
    HTML Code: 
    My adapdted code below:

    Please Login or Register  to view this content.
    However, I think what I'm trying to do is a bit more complex. In fact, there may be a better way to approach this all together. I've attached my data that I'm working with in case it may help solve.

    In Column A, When a new customer# appears I need the following: (if duplicate do nothing)

    Starting at Row 6
    Two rows inserted (I managed to pull this off)
    First row I would like to say TOTAL and have cells F:K autosumd (all in bold text)
    The Second Row I want to color the inside of the cells black A:L


    I can get the two columns inserted but not sure of the best way to do next step. I considered using autofilter and filtering blanks. Then add ToTAL and sum and Bold and black rows and try to apply to rest of rows with copy paste. But its hard to get that approach to work with different data pulls.

    Any help would be greatly appreciated!

    Thanks, Derek.
    Last edited by KapitalD; 06-12-2014 at 08:32 PM.

  2. #2
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Need Macro that inserts two rows with data after value changes

    Hi,

    Please see attached file.

    This is the macro I use to calculate total of each customer for your account.

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


    Cheers
    Lex
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: Need Macro that inserts two rows with data after value changes

    Awesome Lex that's great work!

    Now I just need to figure out how I can bold all the cells on the Sub total rows, and make the next inserted row completely black.

    Thanks for that!

  4. #4
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: Need Macro that inserts two rows with data after value changes

    I would just record the code for autofiltering the blanks inside the current region, or autofilter cells A3 through L3 but the blank rows throw that out of whack.

    I'm thinking I can try to filter the blanks somehow and color them all black.
    Filtering for the word "Total" and bolding those rows should be easy enough.

    I just thought it would be simpler if the row it inserted was already colored in black, and the data was already in bold. But its actually quite difficult for a noob.

  5. #5
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: Need Macro that inserts two rows with data after value changes

    I have included in this post a better file for the raw data. I saved the code above from Lexusap to "This Workbook" so that you can run the code quickly and see how it performs against the raw data. The old file I attached previously needed rows taken out of it anyway before you could run the code that Lexusap provided. This is ready to go.

    Any ideas on the formatting??
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    08-16-2012
    Location
    Sydney
    MS-Off Ver
    Excel 2019
    Posts
    209

    Re: Need Macro that inserts two rows with data after value changes

    Hi KapitalD


    see amended formula. I've added a few extra lines to the original codes.
    copy paste your code and try to run it again.



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



    Thanks
    Lex

  7. #7
    Registered User
    Join Date
    06-10-2014
    Posts
    5

    Re: Need Macro that inserts two rows with data after value changes

    Thanks Lex!

    That works like a charm. I will be using this on the end of month reports this coming Tuesday. Just finishing up the final touches.
    I really appreciate your help with that part. I would not have been able to do that without you.

    Thanks much, Derek.

+ 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: 9
    Last Post: 01-13-2014, 01:49 PM
  2. [SOLVED] Macro that inserts rows stopped working
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-16-2013, 09:57 AM
  3. Macro that Inserts a row in between rows (with formulas etc)
    By How How in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-14-2013, 07:49 AM
  4. Create a Looping macro which copies and inserts rows
    By BenR in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2007, 02:13 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