How to change source data in Pivot table creation in VBA

  • I have below VBA code in my excel sheet:

    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _

    Sheets("Data Entry").Range("A1").CurrentRegion, Version:=xlPivotTableVersion14).CreatePivotTable _

    which should take data from Data Entry tab for a perticular student and puts in other in same student tab in Pivot table. However it takes entire data from "Data Entry" and creates pivot table in other. How can i change source data for new Pivot table so that in a perticular student tab, it justs create pivot table with that student data only.

    File uploaded is the file which i have currently and needs modification.and "Required data" tab shows what i am looking for.

  • You will be better asking this question on an Excel / VBA forum but based on the limited section of code it is missing TableDestination and TableName.

  • I don't think you can - a pivot table is created from all its source data.

    Why don't you just group by Student rather than creating a separate tab for each? Or filter by Student?

  • actually i have a "send email" utility which picks every sheet data which is named after every student...so i was trying to create as many worksheets as there are students and then run the email utility to send an email to every student with the data in their respective sheets.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply