How to create a pivot table using VBA? Assuming that the data for the pivot table is laid out like this, then all you need to create a pivot using vba are there four lines of code:
The pivot table so created using the VBA code above can be further modified. You can make a field appear in the row or field columns by using the following codes.
Say we have a field labeled “my_field_name“. The first one move a field to the row position.
The below code will move the field to the column position.
And finally, this one will move a field to the data field.
Read more about reading data from pivot table