Finance

Charts

Statistics

Macros

Search

  • Home
  • »
  • Excel VBA Course
  • »
  • Example of an application that computes subtotals and manages the outline with Excel VBA

Example of an application that computes subtotals and manages the outline with Excel VBA

We will use the Subtotal method and the Outline object to solve a simple task. We will work with a data list having the following fields: OrderID, ShippingCost, RecipientName, RecipientCity, RecipientCountry, which reflects the necessary shipping expenses for delivering orders to specific customers. We need to obtain summary data on the number of orders placed by each customer and the total postal (shipping) expenses for delivering these orders for each country.

Create a form and place on it a toggle switch, a button, a spin control, a text box, and a label.
When the toggle switch is on, it displays the caption Subtotals applied, and the worksheet will create subtotals that count the number of orders placed by each customer and the total postal (shipping) expenses for delivering these orders.

Clicking the Sort by RecipientCountry button performs sorting by the RecipientCountry field of the list, which must be done before creating the subtotals.

The spin control will allow you to manage the display of different outline levels of the subtotals. When the toggle switch is off, it displays the caption Subtotals removed, and the subtotals are removed from the worksheet. They are also removed when the dialog box is closed.

To complete the application, enter the corresponding code in the form module.

0 0 votes
Évaluation de l'article
S’abonner
Notification pour
guest
0 Commentaires
Le plus ancien
Le plus récent Le plus populaire
Online comments
Show all comments
Facebook
Twitter
LinkedIn
WhatsApp
Email
Print
0
We’d love to hear your thoughts — please leave a commentx