Page 2 of 2 FirstFirst 12
Results 41 to 44 of 44

Thread: SUM of selected cell range

  1. #41
    PowerPoster
    Join Date
    Dec 04
    Posts
    18,532

    Re: SUM of selected cell range

    works correctly for me
    by correctly, i meant the sum showed in the cell, not the formula

    i just pasted your code into my ide and set a range to suit
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  2. #42
    Lively Member
    Join Date
    Jan 12
    Posts
    71

    Re: SUM of selected cell range

    Hi Seenu,

    I got below error:

    Run-time error '1004':

    Method 'Rows' of object '_Global' failed

    Code:
    Sub calculateSubtotalOfRows(sRange As String, sumRowEnd As Integer)
    Dim i As Integer
    
    For i = 1 To sumRowEnd
        sumRowEnd = Cells(Rows.count, i).End(xlUp).Row
        Cells(sumRowEnd + 1, i) = WorksheetFunction.SUM(range(Cells(1, i), Cells(sumRowEnd, i)))
    Next
    
    End Sub

  3. #43
    Lively Member
    Join Date
    Jan 12
    Posts
    71

    Re: SUM of selected cell range

    Value of sRange = B11:R11

    Value of sumRowEnd = 20

  4. #44
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 07
    Location
    India
    Posts
    2,156

    Re: SUM of selected cell range

    Hi Ria,
    which line gives error? can u attach the file u tried?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •