Attribute VB_Name = "Module9" Public Sub CreatePivotTable(ByVal colonyNum) Dim PTCache As PivotCache Dim PT As PivotTable Set PTCache = ActiveWorkbook.PivotCaches.Add _ (SourceType:=xlDatabase, _ SourceData:=Range("A1000").CurrentRegion.Address) Set PT = PTCache.CreatePivotTable _ (TableDestination:=Sheets("EzyMate Results - Colony " & colonyArray(colonyNum)).Range(pivotRange), _ TableName:="PivotTable1") With PT .PivotFields("Loci").Orientation = xlPageField .PivotFields("Statistic").Orientation = xlColumnField .PivotFields("Alleles").Orientation = xlRowField .PivotFields("Results").Orientation = xlDataField End With End Sub