Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default need help creating "AutoSubtotal" toolbar button

Similar to how the AutoSum toolbar button enters a =SUM formula into a
cell, I'm trying to create an "AutoSubtotal" button that would enter a
=SUBTOTAL formula into a cell. (I'm not trying to do DataSubtotal. I
just want to enter a =SUBTOTAL formula into the cell.)

I thought this would work, but it doesn't. Any help would be greatly
appreciated.


Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then End
Else
ActiveCell.Formula = "=subtotal(9," & _
Range(ActiveCell.Offset(-1, 0).End(xlUp), _
ActiveCell.Offset(-1, 0)) & ")"
End If
End Sub


(I need the cell to actually contain a formula, so I can't use
WorksheetFunction.)

Many thanks,
Paul
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default need help creating "AutoSubtotal" toolbar button

Paul,

Try this version:

Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then
Else
ActiveCell.Formula = "=subtotal(9," & _
ActiveCell.Offset(-1, 0).End(xlUp).Address _
& ":" & ActiveCell.Offset(-1, 0).Address & ")"
End If
End Sub

--
sb
"Paul Simon" wrote in message
m...
Similar to how the AutoSum toolbar button enters a =SUM formula into a
cell, I'm trying to create an "AutoSubtotal" button that would enter a
=SUBTOTAL formula into a cell. (I'm not trying to do DataSubtotal. I
just want to enter a =SUBTOTAL formula into the cell.)

I thought this would work, but it doesn't. Any help would be greatly
appreciated.


Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then End
Else
ActiveCell.Formula = "=subtotal(9," & _
Range(ActiveCell.Offset(-1, 0).End(xlUp), _
ActiveCell.Offset(-1, 0)) & ")"
End If
End Sub


(I need the cell to actually contain a formula, so I can't use
WorksheetFunction.)

Many thanks,
Paul



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default need help creating "AutoSubtotal" toolbar button

Tom and Steve,

Both solutions work perfectly. Thank you both for responding to my
question and for taking the time to work out the code for me - I
appreciate it very much.

Many thanks,
Paul


"steve" wrote in message ...
Paul,

Try this version:

Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then
Else
ActiveCell.Formula = "=subtotal(9," & _
ActiveCell.Offset(-1, 0).End(xlUp).Address _
& ":" & ActiveCell.Offset(-1, 0).Address & ")"
End If
End Sub

--
sb
"Paul Simon" wrote in message
m...
Similar to how the AutoSum toolbar button enters a =SUM formula into a
cell, I'm trying to create an "AutoSubtotal" button that would enter a
=SUBTOTAL formula into a cell. (I'm not trying to do DataSubtotal. I
just want to enter a =SUBTOTAL formula into the cell.)

I thought this would work, but it doesn't. Any help would be greatly
appreciated.


Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then End
Else
ActiveCell.Formula = "=subtotal(9," & _
Range(ActiveCell.Offset(-1, 0).End(xlUp), _
ActiveCell.Offset(-1, 0)) & ")"
End If
End Sub


(I need the cell to actually contain a formula, so I can't use
WorksheetFunction.)

Many thanks,
Paul

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default need help creating "AutoSubtotal" toolbar button

Paul,

Glad we could be of help!

--
sb
"Paul Simon" wrote in message
om...
Tom and Steve,

Both solutions work perfectly. Thank you both for responding to my
question and for taking the time to work out the code for me - I
appreciate it very much.

Many thanks,
Paul


"steve" wrote in message

...
Paul,

Try this version:

Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then
Else
ActiveCell.Formula = "=subtotal(9," & _
ActiveCell.Offset(-1, 0).End(xlUp).Address _
& ":" & ActiveCell.Offset(-1, 0).Address & ")"
End If
End Sub

--
sb
"Paul Simon" wrote in message
m...
Similar to how the AutoSum toolbar button enters a =SUM formula into a
cell, I'm trying to create an "AutoSubtotal" button that would enter a
=SUBTOTAL formula into a cell. (I'm not trying to do DataSubtotal. I
just want to enter a =SUBTOTAL formula into the cell.)

I thought this would work, but it doesn't. Any help would be greatly
appreciated.


Sub AutoSubtotal()
If ActiveCell.Offset(-1, 0).Formula = "" Then End
Else
ActiveCell.Formula = "=subtotal(9," & _
Range(ActiveCell.Offset(-1, 0).End(xlUp), _
ActiveCell.Offset(-1, 0)) & ")"
End If
End Sub


(I need the cell to actually contain a formula, so I can't use
WorksheetFunction.)

Many thanks,
Paul



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
toolbar "button" for hiding/unhiding sheets Barb in MD Excel Worksheet Functions 2 February 10th 10 01:45 AM
Creating a "Next" button to move the user to the next sheet Rob Excel Discussion (Misc queries) 2 March 29th 09 12:14 PM
Diff. change headline in "Formatting" or "Outlining" toolbar? Bernd Oninger Excel Discussion (Misc queries) 1 November 10th 08 11:02 PM
Add "Equation 3.0" button to Excel toolbar. DarrenL Setting up and Configuration of Excel 1 May 16th 08 02:10 AM
Any way to use toolbar button to delete cells and move cells "up"? Texas-Ron Excel Discussion (Misc queries) 2 April 7th 07 06:33 PM


All times are GMT +1. The time now is 12:50 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"