Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

vba excel - functions

Forum home » Delegate support and help forum » Microsoft Excel Training and help » vba excel - Functions

vba excel - Functions

ResolvedVersion Standard

Andy has attended:
Access Introduction course
Excel VBA Intro Intermediate course

Functions

Pivot tables

RE: Functions

Andy

Below is the code to create a pivot table in VBA

====================

Sub CreatePivot()

Dim DataRange As Range
Dim Destination As Range
Dim PvtTable As PivotTable

Set Destination = Sheets("Sales Summary").Range("A12")
Set DataRange = Range("A9", Range("J9").End(xlDown))

ActiveSheet.PivotTableWizard SourceType:=xlDatabase, _
SourceData:=DataRange, TableDestination:=Destination, TableName:="SalesInfo"

Application.CommandBars("PivotTable").Visible = False 'Hides toolbar
ActiveWorkbook.ShowPivotTableFieldList = False 'Hides Field List

Set PvtTable = Sheets("Sales Summary").PivotTables("SalesInfo")

With PvtTable
.PivotFields(

 

Training courses

Training information:

See also:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.

Excel tip:

Shortcuts for working with named ranges in Excel

If you are working with or creating named ranges in your spreadsheets, then you may find the following shortcut keys useful.

- Bring up the Define Names dialogue box on screen by using Ctrl + F3 (instead of going to Insert - Names).

- Create Names from labels you have entered into the spreadsheet by highlighting the labels and related figures, then hold down Shift + Ctrl + F3. You can then choose to create names from the top or bottom rows, or left or right columns.

- Go directly to a named range by hitting the F5 key. The Go To dialogue box will open and display any named ranges in the spreadsheet. Simply select the named range to navigate to it in the spreadsheet.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.11 secs.