+ Reply to Thread
Results 1 to 4 of 4

Summing rows in a column up to a specific value

  1. #1
    Registered User
    Join Date
    11-29-2012
    Location
    New York, New York
    MS-Off Ver
    Excel 2011
    Posts
    1

    Summing rows in a column up to a specific value

    Hi, I am trying to figure out how to highlight certain cells in a column up to a point where the column numbers add up to a specific value.

    For example

    Col A
    10
    15
    3
    15

    If I want to know how how far down the list I can go up until the sum of the rows is less than or equal to 26. I this case, I would like to highlight the first two rows.

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Summing rows in a column up to a specific value

    Sub Macro1()
    '
    ' Macro1 Macro
    '

    '
    Dim j, jmin, sm, value As Double

    Worksheets("sheet4").Select

    ' desired value in your case 26 should be placed in A1

    value = Cells(1, 1)
    j = 3
    sm = 0
    While sm < value And Cells(j, 1) <> ""
    sm = sm + Cells(j, 1)
    If sm < value Then
    Range("A" & j).Select
    With Selection.Interior
    .Pattern = xlSolid
    .PatternColorIndex = xlAutomatic
    .Color = 65535
    .TintAndShade = 0
    .PatternTintAndShade = 0
    End With
    End If
    j = j + 1
    Wend
    End Sub

  3. #3
    Banned User!
    Join Date
    10-14-2006
    Posts
    1,211

    Re: Summing rows in a column up to a specific value

    =sum($a$1:$a1)<=26

  4. #4
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: Summing rows in a column up to a specific value

    hi
    in conditional formatting, apply this formular to cell A! (assuming its the first in the sequence) then copy > paste special > paste format to the other cells:

    Please Login or Register  to view this content.
    then select the format you want

+ 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