• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Subtotal

Hi Ashish ,

Something like this :
Code:
Public Sub InsertSubtotalFormula()
           Dim Lastrow As Long
           Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
           Cells(Lastrow + 1, "A").Formula = "=SUBTOTAL(3,A2:A" & Lastrow & ")"
End Sub
Narayan
 
Hi Ashish,

I don't know the exact model where you are going to use this, but if this calculation is not on the display sheet and you are using in intermediate calculation than why not define a named formula to get last row and use SUBTOTAL in top row (as illustrated in the file).

Pros which I feel:
1. I don't have to run the sub-routine every time.
2. I don't have to scroll down in case of large data set to see the total.

Ignore this comment if VBA is must.

Regards,
 

Attachments

  • subtotal.xls
    27.5 KB · Views: 6
Hi SM,

Thanks for your valuable comments.:cool:

I am preparing an automate report in which I am missing on the Subtotal step; without this step my project was incomplete; in case the number of rows are increased. However, I will consider your suggestion.

One thing I have not understood;

the Lastrow function; Is it in-built, UDF or ?

Regards,
AM:)
 
Back
Top