The Tech Edvocate

Top Menu

  • Advertisement
  • Apps
  • Home Page
  • Home Page Five (No Sidebar)
  • Home Page Four
  • Home Page Three
  • Home Page Two
  • Home Tech2
  • Icons [No Sidebar]
  • Left Sidbear Page
  • Lynch Educational Consulting
  • My Account
  • My Speaking Page
  • Newsletter Sign Up Confirmation
  • Newsletter Unsubscription
  • Our Brands
  • Page Example
  • Privacy Policy
  • Protected Content
  • Register
  • Request a Product Review
  • Shop
  • Shortcodes Examples
  • Signup
  • Start Here
    • Governance
    • Careers
    • Contact Us
  • Terms and Conditions
  • The Edvocate
  • The Tech Edvocate Product Guide
  • Topics
  • Write For Us
  • Advertise

Main Menu

  • Start Here
    • Our Brands
    • Governance
      • Lynch Educational Consulting, LLC.
      • Dr. Lynch’s Personal Website
      • Careers
    • Write For Us
    • The Tech Edvocate Product Guide
    • Contact Us
    • Books
    • Edupedia
    • Post a Job
    • The Edvocate Podcast
    • Terms and Conditions
    • Privacy Policy
  • Topics
    • Assistive Technology
    • Child Development Tech
    • Early Childhood & K-12 EdTech
    • EdTech Futures
    • EdTech News
    • EdTech Policy & Reform
    • EdTech Startups & Businesses
    • Higher Education EdTech
    • Online Learning & eLearning
    • Parent & Family Tech
    • Personalized Learning
    • Product Reviews
  • Advertise
  • Tech Edvocate Awards
  • The Edvocate
  • Pedagogue
  • School Ratings

logo

The Tech Edvocate

  • Start Here
    • Our Brands
    • Governance
      • Lynch Educational Consulting, LLC.
      • Dr. Lynch’s Personal Website
        • My Speaking Page
      • Careers
    • Write For Us
    • The Tech Edvocate Product Guide
    • Contact Us
    • Books
    • Edupedia
    • Post a Job
    • The Edvocate Podcast
    • Terms and Conditions
    • Privacy Policy
  • Topics
    • Assistive Technology
    • Child Development Tech
    • Early Childhood & K-12 EdTech
    • EdTech Futures
    • EdTech News
    • EdTech Policy & Reform
    • EdTech Startups & Businesses
    • Higher Education EdTech
    • Online Learning & eLearning
    • Parent & Family Tech
    • Personalized Learning
    • Product Reviews
  • Advertise
  • Tech Edvocate Awards
  • The Edvocate
  • Pedagogue
  • School Ratings
  • US Battery as a Service Market Shifts Toward Fleet-Based Energy

  • The Startling Truth: Why Americans Distrust AI with Their Health

  • This Crucial Deadline for Banks Is Closer Than You Think

  • Baffling: CrowdStrike’s $500 Million AI Bet Reshapes Cybersecurity

  • This Crucial Autonomous Driving Rule Could Cost You Everything

  • Baffling: Microsoft AI CEO Demands Halt to Conscious AI Development

  • O seară în ritmul tău: atmosfera divertismentului de cazinou pe internet

  • Outrageous: AppLovin Hit With Lawsuit Over AI Claims — What Investors Need to Know

  • 9 Critical Ways AI Investment Fraud Is Quietly Draining Your Bank Account

  • Is the AI Bubble Bursting? OpenAI’s Funding Woes Revealed

Assistive Technology
Home›Assistive Technology›Learn How to Automatically Create Pivot Tables in Excel With VBA

Learn How to Automatically Create Pivot Tables in Excel With VBA

By Matthew Lynch
August 5, 2023
0
Spread the love

Pivot tables are powerful tools which help transform data into meaningful insights. They can help you understand patterns and trends, make accurate forecasts, and improve your decision-making skills. However, creating pivot tables manually is a tedious and time-consuming task. This is where VBA (Visual Basic for Applications) comes into play. In this article, we will learn how to create pivot tables automatically in Excel using VBA.

Step 1: Enable Developer Tab

Before we start coding, we need to enable the Developer tab in Excel. To do this, go to the File tab, choose Options, then click Customize Ribbon. Check the box next to Developer, and then click OK.

Step 2: Open Visual Basic Editor

To write VBA code, we need to open the Visual Basic Editor. Click the Developer tab, then click the Visual Basic button. Alternatively, you can press ALT + F11 on your keyboard to open the Editor.

Step 3: Insert Module

In the Visual Basic Editor, go to the Insert menu and choose Module. This creates a new module where we can write our VBA code.

Step 4: Write the VBA Code

We will now write the VBA code which will create the pivot table. The first line of code declares a pivot table object. The second line creates a new pivot table based on the data in the selected range. The rest of the code sets the fields in the pivot table – row fields, column fields, value fields, and filters.

Sub CreatePivotTable()

Dim pt As PivotTable

Set pt = ActiveSheet.PivotTableWizard

With pt

.PivotFields(“Category”).Orientation = xlRowField

.PivotFields(“Product”).Orientation = xlRowField

.PivotFields(“Units Sold”).Orientation = xlDataField

.PivotFields(“Revenue”).Orientation = xlDataField

End With

End Sub

Step 5: Run the Code

Once we have written the VBA code, we need to run it. There are two ways to run the code: by pressing F5 on your keyboard, or by clicking the Run button in the toolbar.

Step 6: Customize the Pivot Table

By default, the pivot table will be created in a new worksheet. You can now customize the pivot table by dragging and dropping fields to different areas, formatting the table, and adding charts.

Conclusion

Using VBA to create pivot tables in Excel can save you a lot of time and effort. With just a few lines of code, you can create a pivot table that summarizes and analyzes your data. VBA is a powerful tool that can automate repetitive tasks and improve your productivity. By learning how to use VBA in Excel, you can become a more efficient and effective data analyst.

Previous Article

Where to Buy Refurbished MacBooks: The Best ...

Next Article

Minecraft Redstone Explained: What Is It and ...

Matthew Lynch

Related articles More from author

  • Assistive Technology

    How to Remove the Chat Button From the Windows 11 Taskbar

    June 15, 2023
    By Matthew Lynch
  • Assistive Technology

    How to Print From Your iPhone or iPad: A Simple Guide

    June 14, 2023
    By Matthew Lynch
  • Assistive Technology

    How to Download Hulu Shows to Watch Offline

    June 21, 2023
    By Matthew Lynch
  • Assistive Technology

    How to Access the Windows 10 Startup Folder

    June 10, 2023
    By Matthew Lynch
  • Assistive Technology

    How to Fix Error Code 0x80070422 in Windows 10

    June 14, 2023
    By Matthew Lynch
  • Assistive Technology

    How to Superscript and Subscript in Google Slides

    June 8, 2023
    By Matthew Lynch

Search

Login & Registration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Newsletter

Signup for The Tech Edvocate Newsletter and have the latest in EdTech news and opinion delivered to your email address!

About Us

Since technology is not going anywhere and does more good than harm, adapting is the best course of action. That is where The Tech Edvocate comes in. We plan to cover the PreK-12 and Higher Education EdTech sectors and provide our readers with the latest news and opinion on the subject. From time to time, I will invite other voices to weigh in on important issues in EdTech. We hope to provide a well-rounded, multi-faceted look at the past, present, the future of EdTech in the US and internationally.

We started this journey back in June 2016, and we plan to continue it for many more years to come. I hope that you will join us in this discussion of the past, present and future of EdTech and lend your own insight to the issues that are discussed.

Newsletter

Signup for The Tech Edvocate Newsletter and have the latest in EdTech news and opinion delivered to your email address!

Contact Us

The Tech Edvocate
910 Goddin Street
Richmond, VA 23231
(601) 630-5238
[email protected]

Copyright © 2026 Matthew Lynch. All rights reserved.