+ Reply to Thread
Results 1 to 4 of 4

Sum of relative cell in a column

  1. #1
    Registered User
    Join Date
    07-27-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    53

    Lightbulb Sum of relative cell in a column

    Hi

    I have the code below which get the sum of the data in a column irrespective of the data range. But now the no. of topRow is not a constant one. Everyday I have to change the value of the vRowTop. Is there any way that macro counts the value for vRowTop itself?
    The rows above the range sometimes contain Blank cell and somtimes data.

    vRowTop = 5
    vRowBottom = ActiveCell.Offset(-1, 0).Row
    vDiff = vRowBottom - vRowTop + 1
    Selection.FormulaR1C1 = "=SUM(R[" & -vDiff & "]C:R[-1]C)"
    Thanks
    Chetan
    Last edited by Chetan Chauhan; 07-30-2009 at 08:01 AM. Reason: Code Tag

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sum of relative cell in a column

    Is there any way by which you can always determine vRowTop ? Does the cell of interest always contain a value of some sort, is it the first row of data etc etc...

    It might be an idea to post a sample file which illustrates exactly how you're using the above code.

  3. #3
    Registered User
    Join Date
    07-27-2009
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    53

    Re: Sum of relative cell in a column

    Hi Donkeyote,

    Please find the sheet attached. Previously the cell above the 5th cell were empty and the value starts from 5th row but now it has some data in the above cell and the range to be calculate starts from 5th,6th or from 11th even sometimes which is not fixed.

    Hope this will help.

    Thanks
    Chetan
    Attached Files Attached Files

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sum of relative cell in a column

    Sorry, I still don't follow... in order for you to automate something you really need for there to exist some underlying "logic"... ie if the start row is decided on a "whim" then it can't be automated...

    Thus far you've not really provided any info which we could deem as logic to determine as to why you start at row 5 once, then sometimes row 6, or row 11 etc...

+ 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