• 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.

Syntax Subtotal with variable

Pierre

Member
Hello,
I would like to make my subtotal calculation depending on variable.

Right my formula is on the whole G Column:
Application.WorksheetFunction.Subtotal(9, Range("G:G"))

I add 2 variable (lmin and lmax) which will determine the first and last line to use

I tried this but doesn't work
Application.WorksheetFunction.Subtotal(9, Range(Cells(lmin, "G"), Cells(lmax, "G"))

Thanks in advance for helping
 
Indeed :p, I thought I did that but seems not

In the same area, I'd like to change the following formula:
Evaluate("=MATCH(SUBTOTAL(5,(K:K)),K:K,0)")

So that the range are Klmin:Klmax
 
You need to concatenate them in:

Code:
Evaluate("=MATCH(SUBTOTAL(5,(K" & lmin & ":K" & lmax & ")),K" & lmin & ":K" & lmax & ",0)")
 
That's seem to do the trick :)
Thanks a lot, it's always a bit difficult for me do manage variable in range :p
 
Back
Top