VBA (Visual Basic for Applications) is the programming language used to create macros. A good knowledge of VBA can save time and make you a much more productive Excel user. VBA is a common programming language found in virtually all Microsoft Office applications. People will often learn VBA before progressing to other languages in due course.
In this tutorial I will be showing you some code so that you will be able to create your own pivot table sing VBA. The code below is the code I got when I created my pivot table this means you are going to have to change a couple of things before it will work for you.
The first part you are going to need to change the source data which is located in the red box below you are just going to need to change it to the range you want.
The next thing you are going to need to change is the table destination, mine is going to be put into sheet2 but you might want to have in sheet1.
The next part is not important but you might find it useful you might also want change the name of the pivot table rather than keeping it as PivotTable3. Now you should be able to run it and have a pivot table crated.