Thank you Mr Paul, for the detailed explanation. I missed to include the
keyword Range and the Quotes.
It works now.

Regards
Eugene

On Fri, Jan 9, 2015 at 12:58 AM, Paul Schreiner <schreiner_p...@att.net>
wrote:

> OK,
> In your macro, you're trying to the use the Subtotal worksheet function.
>
> First, you need to understand the requirements for the Subtotal function.
>
> In Excel, the function looks like:
> Subtotal(function_num,range1,range2, etc.)
> (at least 1 range is required)
>
> In your case, you tried:
> MsgBox WorksheetFunction.Subtotal(9, B2, B9)
>
> In VBA, you've just said to use the number 9 as the function number (which
> is for SUM)
> but you said to use a VARIABLE called B2 and B9 as the first and second
> ranges.
>
> Now, if you've done something like:
>
> Dim B2 as Range
> Dim B9 as Range
>
> Then something like:
>
>     Set B2 = Range("B2:B8")
>     Set B9 = Range("B9")
>
> Then your statement:
> MsgBox WorksheetFunction.Subtotal(9, B2, B9)
> would work.
>
> However, I SUSPECT that what you were trying to do is get the subtotal of
> B2 THRU B9
> which would be like "B2:B9"
>
> Even the, "B2:B9" doesn't define a RANGE, it defines a STRING.
>
> you need to tell VBA to interpret the string as a range.
>
> MsgBox WorksheetFunction.Subtotal(9, Range("B2:B9"))
>
> should work.
>
>
> *Paul*
> -----------------------------------------
>
>
>
>
>
>
>
> *“Do all the good you can,By all the means you can,In all the ways you
> can,In all the places you can,At all the times you can,To all the people
> you can,As long as ever you can.” - John Wesley*
> -----------------------------------------
>
>    *From:* Eugene Bernard <eugene.bern...@gmail.com>
> *To:* excel-macros@googlegroups.com
> *Sent:* Thursday, January 8, 2015 11:50 AM
> *Subject:* $$Excel-Macros$$ Worksheet Function
>
> Please find attached a sheet, where i am facing a error in the
>
> one liner macro.
>
> TIA
>
> Regards
> Eugene
> --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/d/optout.
>
>
>    --
> Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s
> =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @
> https://www.facebook.com/discussexcel
>
> FORUM RULES
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
> 2) Don't post a question in the thread of another member.
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
> 4) Acknowledge the responses you receive, good or bad.
> 5) Jobs posting is not allowed.
> 6) Sharing copyrighted material and their links is not allowed.
>
> NOTE : Don't ever post confidential data in a workbook. Forum owners and
> members are not responsible for any loss.
> ---
> You received this message because you are subscribed to the Google Groups
> "MS EXCEL AND VBA MACROS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to excel-macros+unsubscr...@googlegroups.com.
> To post to this group, send email to excel-macros@googlegroups.com.
> Visit this group at http://groups.google.com/group/excel-macros.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s 
=TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ 
https://www.facebook.com/discussexcel

FORUM RULES

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.
2) Don't post a question in the thread of another member.
3) Don't post questions regarding breaking or bypassing any security measure.
4) Acknowledge the responses you receive, good or bad.
5) Jobs posting is not allowed.
6) Sharing copyrighted material and their links is not allowed.

NOTE  : Don't ever post confidential data in a workbook. Forum owners and 
members are not responsible for any loss.
--- 
You received this message because you are subscribed to the Google Groups "MS 
EXCEL AND VBA MACROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to excel-macros+unsubscr...@googlegroups.com.
To post to this group, send email to excel-macros@googlegroups.com.
Visit this group at http://groups.google.com/group/excel-macros.
For more options, visit https://groups.google.com/d/optout.

Reply via email to