+ Reply to Thread
Results 1 to 2 of 2

Summing a Column with Blanks

  1. #1
    Registered User
    Join Date
    06-13-2006
    Posts
    46

    Summing a Column with Blanks

    I have a problem trying to set the references to sum/subtotal a colum with blanks. I have the macro written to find the next blank cell starting at the bottom of my data and working up but I can't get the formula right to sum the numbers above. Here is what my data looks like

    Supplier Debit Credit
    Vendor A $60 $25
    Vendor A $75 $15
    Vendor A $55 $35
    Sum Blank Blank
    Vendor B $60 $40
    Vendor B $125 $25
    Sum Blank Blank
    Vendor C $65 $14

    So I want the blanks to be the sum of the numbers above them. I am working from the bottom up so I don't know how to reference the cells to add when they vary (i.e. not always the same number of rows for each vendor. here is my code so far
    Sub Macro6()
    '
    ' Macro6 Macro
    ' Macro recorded 2/27/2007 by User
    '

    Dim ws As Worksheet
    Dim myCol As Long, lastRow As Long
    Dim i As Long, firstRow As Long
    Dim strHeader As String

    Set ws = ActiveSheet

    myCol = 3
    firstRow = 2
    'find last Row in myCol
    lastRow = ws.Cells(ws.Rows.Count, 3).End(xlUp).Row

    For i = lastRow To firstRow Step -1
    If Cells(i, myCol + 2) = "" Then
    Cells(i, myCol + 2).Select
    ActiveCell.FormulaR1C1 = "=SUM($R$C:$R$C)"
    End If
    Next i

    End Sub

    Any help would be greatly appreciated
    Last edited by Lvenom; 02-28-2007 at 01:37 AM.

  2. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591
    Hi

    Try


    Please Login or Register  to view this content.

    rylo

+ 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