+ Reply to Thread
Results 1 to 4 of 4

need excel macro, to add two blank rows after a value change, then autosum column C

  1. #1
    Registered User
    Join Date
    04-30-2015
    Location
    USA
    MS-Off Ver
    EXCEL 2007
    Posts
    1

    need excel macro, to add two blank rows after a value change, then autosum column C

    so the column is:

    1
    1
    1
    2
    2
    2

    I want it to do this:
    1
    1
    1
    autosum column C

    2
    2
    2



    I found a similar one but it does it for column E. I need it for column C and I need to add two rows after every value change.

    Sub sbttls()
    Dim aArea As Range, i As Integer
    i = 0
    For Each aArea In ActiveSheet.UsedRange.SpecialCells(xlCellTypeConstants).Areas
    i = i + 1
    If i <> 1 Then
    With Cells(aArea.Row + aArea.Rows.Count, 5)
    .Value = WorksheetFunction.Sum(Range(Cells(aArea.Row, 5), Cells(aArea.Row + aArea.Rows.Count - 1, 5)))
    With .Font
    .ColorIndex = 5
    .Bold = True
    End With
    End With
    End If
    Next aArea
    End Sub

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: need excel macro, to add two blank rows after a value change, then autosum column C

    Hello and welcome to the forum,

    Try this code :
    Please Login or Register  to view this content.
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Expert
    Join Date
    12-24-2007
    Location
    Alsace - France
    MS-Off Ver
    MS 365 Office Suite
    Posts
    5,066

    Re: need excel macro, to add two blank rows after a value change, then autosum column C

    Another way
    If you don't want the first block to have the SUM, remove the "'" at the beginning of
    Please Login or Register  to view this content.



    Please Login or Register  to view this content.
    - Battle without fear gives no glory - Just try

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

    Re: need excel macro, to add two blank rows after a value change, then autosum column C

    One more:

    Please Login or Register  to view this content.

+ 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: 3
    Last Post: 04-22-2014, 02:12 PM
  2. Replies: 8
    Last Post: 12-09-2013, 09:05 PM
  3. Macro to delete blank rows if column I is blank for the row
    By tiger10012 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-10-2013, 03:01 PM
  4. Macros to insert 2 blank row and autosum a column after every 200 rows in data range.
    By sachinsingh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-22-2013, 09:55 AM
  5. Change AutoSum Direction in Excel
    By e@london in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 08-15-2012, 06:55 AM

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