Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel97 using Visual Basic

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
When selecting a Range using Variable1 and Variable2, how can you use Subtotal as a formula?<br>Within Excel, for example, the Formula for a Subtotal of the Sum is =Subtotal(9,A1:A9). How can this be written in Visual Basic Code?<br>I have no problem with using Sum.<br>Total = Range(Variable1,Variable2)<br>mysum = Application.Sum(Total)<br>The same does not work for SubTotal.<br>I would be pleased if sombody could assist.<br>regards,<br>Kevsim
 
Its not pretty but a simple way is to use worksheetfunction.

MyRange=&quot;A1:A9&quot;
MyAnswer = Application.WorksheetFunction.Subtotal(9,MyRange)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top