It puts the formula in the activecell - as you asked.

--
Regards,
Tom Ogilvy

"enyaw" <enyaw@discussions.microsoft.com> wrote in message
news:07DB49F4-2A31-4EAD-972B-76A87D3AD4DB@microsoft.com...
> Is there a way of getting this formula to use the active cell as a

reference
> to the row that needs the subtotal formula instead of having to type it in

in
> the program?
>
> "Tom Ogilvy" wrote:
>
> > Private sub commandbutton1_Click()
> > activecell.FormulaR1C1 = "=Subtotal(9,R2C:R[-1]C)"
> > end Sub
> >
> > the R2C says to start the sum in Row 2 of the same column as the

formula.
> > Adjust the 2 to reflect the start of your data.
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "enyaw" wrote:
> >
> > > I need to input the subtotals automatically. Is there a way of

inputting the
> > > subtotal row via programming and add it to a command button. I need

to know
> > > if there is a way to input the subtotal from the cell that the cursor

is in.
> > >
> > > "NickHK" wrote:
> > >
> > > > enyaw,
> > > > Does the Data>Subtotals achieve your goal ?
> > > >
> > > > NickHK
> > > >
> > > > "enyaw" <enyaw@discussions.microsoft.com> wrote in message
> > > > news:FE12189D-23E7-4DF3-91FB-00731372954E@microsoft.com...
> > > > > I am creating a template to calulate information that is

downloaded from
> > > > > another program. The information is downloaded into different

sheets and
> > > > i
> > > > > need to do lookups to bring the information into one sheet. The

problem i
> > > > > have is that there are subtotals to be placed on the sheet but the
> > > > > information is not always in the same format. In one download

there may
> > > > be
> > > > > four items to calculate while in another download there may be

only three.
> > > > > Is there any programming I can use to calculate the subtotals once

all the
> > > > > items are in place?
> > > > >
> > > > > Thanks
> > > >
> > > >
> > > >