Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA Clear Subtotal Buttons

Posted on 2014-04-08
9
Medium Priority
?
841 Views
Last Modified: 2014-04-13
I have a Excel Workbook with multiple sheets that have subtotals. I would like to remove the subtotal buttons with VBA on all sheets.
0
Comment
Question by:shieldsco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 19

Expert Comment

by:regmigrant
ID: 39986299
Do you mean the subtotal fomula (eg: =subtotal(9,A1:a5) or that there is a Row/Column labelled 'subtotal' or that there is an actual button marked 'subtotal' and you want to delete it ?
0
 

Author Comment

by:shieldsco
ID: 39986309
No the subtotal buttons on the left. Manually I can go to Data. Ungroup and clea outline
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39986331
assuming the data starts in A1 - try:


    Range("A1").Select
    Selection.RemoveSubtotal
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:shieldsco
ID: 39986370
I do not want to remove sutotals --I want to clear the outline.. clearoutline on all sheets in the workbook
0
 

Accepted Solution

by:
shieldsco earned 0 total points
ID: 39986408
I figured it out -- here is the code:
'Clear Subtotal Buttons
  Application.ScreenUpdating = False
    Dim wkSt As String
    Dim wkBk As Worksheet
    wkSt = ActiveSheet.Name
    For Each wkBk In ActiveWorkbook.Worksheets
        On Error Resume Next
        wkBk.Activate
        Selection.ClearOutline
               
               
    Next wkBk
    Sheets(wkSt).Select
    Application.ScreenUpdating = True
0
 

Author Comment

by:shieldsco
ID: 39986442
'Clear Subtotal Buttons
  Application.ScreenUpdating = False
    Dim wkSt As String
    Dim wkBk As Worksheet
    wkSt = ActiveSheet.Name
    For Each wkBk In ActiveWorkbook.Worksheets
        On Error Resume Next
        wkBk.Activate
        Selection.ClearOutline
               
               
    Next wkBk
    Sheets(wkSt).Select
    Application.ScreenUpdating = True
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39986639
that's not the question that was asked - but whatever
0
 

Author Closing Comment

by:shieldsco
ID: 39997144
I was able to figure out the solution without help from an expert.
0
 
LVL 19

Expert Comment

by:regmigrant
ID: 39997497
its gone beyond the points but if you are asking questions please try to be explicit about what you are trying to achieve:-

your question:
"I would like to remove the subtotal buttons with VBA on all sheets. "

the answer you came up with:-
"Selection.ClearOutline"

Apart from not explaining what you meant by 'Subtotal buttons' you seem to be unaware that Outlines and Subtotals are different things - so it was a waste of time for all concerned.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question