+ Reply to Thread
Results 1 to 5 of 5

Autosum from last row up to first blank

  1. #1
    Registered User
    Join Date
    12-26-2010
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    11

    Autosum from last row up to first blank

    Hello folks, I have been a member here for.... Well, years lol. and this is my first post.
    Lurked and found a lot of info here, but with this one im a bit stumped.
    Hoping someone can help

    So I have this Macro that works well, I however only want to total the last chunk of data (17 - 20 rows) at a time. The total is manipulated in some cases based on other criteria, and with this maco, everytime i add another chunk and rerun this macro it resets my maniplulated totals.
    The ideal solution is for an autosum just the last chunk, from the bottom row up to the first blank. Then as you will see its stored in 2 places.
    Hope that makes sense. here is the code


    Sub AutoSum2()
    Const SourceRange = "H:H"
    Dim NumRange As Range, formulaCell As Range
    Dim SumAddr As String
    Dim c As Long

    For Each NumRange In Columns(SourceRange).SpecialCells(xlConstants, xlNumbers).Areas
    SumAddr = NumRange.Address(False, False)


    Set formulaCell = NumRange.Offset(NumRange.Count, 4).Resize(1, 1)
    formulaCell.Formula = "=SUM(" & SumAddr & ")"
    Set formulaCell = NumRange.Offset(NumRange.Count, 1).Resize(1, 1)
    formulaCell.Formula = "=SUM(" & SumAddr & ")"

    'change formatting to your liking:
    formulaCell.Font.Bold = True
    formulaCell.Font.Color = RGB(255, 0, 0)
    formulaCell.Interior.ColorIndex = 6
    c = NumRange.Count
    Next NumRange

    End Sub

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

    Re: Autosum from last row up to first blank

    It will be easier and faster if you were to attach a short Excel sample showing final result ...!
    - Battle without fear gives no glory - Just try

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

    Re: Autosum from last row up to first blank

    Perhaps next code !!!!
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    12-26-2010
    Location
    UK
    MS-Off Ver
    Excel 2016
    Posts
    11

    Re: Autosum from last row up to first blank

    LOL. Thanks guys, I am officially embarrassed for missing the obvious.

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

    Re: Autosum from last row up to first blank

    No, do not worry, I have the feeling to help a little bit ...!

+ 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: 05-01-2015, 06:26 AM
  2. [SOLVED] Insert a blank row and calculate autosum
    By pani_hcu in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-23-2014, 05:58 PM
  3. 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
  4. [SOLVED] Autosum with VBA
    By drawing.blanks in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-15-2012, 07:45 PM
  5. Insert Blank Row and AutoSum Formula
    By StinkBall in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2011, 04:59 PM
  6. Autosum
    By dayaptl in forum Excel General
    Replies: 1
    Last Post: 03-25-2006, 01:00 PM
  7. [SOLVED] Autosum
    By Stuart Perry in forum Excel General
    Replies: 5
    Last Post: 07-19-2005, 04:05 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