Hello,
I’m using something that’s already been made into Excel macro and I’d like to add a specific phrase.
But I don’t know where to put it
I put it in the place where I think it’s okay to put it in
Only that particular phrase doesn’t work.
I’d appreciate it if you could tell me where to put this phrase.
→ RepeatAllLabels xlRepeatLabels
( ActiveSheet.PivotTables(“pivot”).RepeatAllLabels xlRepeatLabels )
20231016.xlsx (31.0 KB)
Macro.txt (1.2 KB)
1 Like
Here you should add it within the With pt
block, which configures the PivotTable
This is the complete modified code
Sub macro()
Sheets.Add
ActiveSheet.Name = "Pivot"
Dim pt As PivotTable
Dim pc As PivotCache
Dim sd As Worksheet, ss As Worksheet
Dim cs As Range, cd As Range
Set ss = Sheets("53_DELELE")
Set sd = Sheets("Pivot")
Set cs = ss.Range("a1")
Set cd = sd.Range("a1")
sd.Activate
sd.Cells.Clear
Set pc = ThisWorkbook.PivotCaches.Create(xlDatabase, cs.CurrentRegion)
Set pt = pc.CreatePivotTable(cd, "pivot")
With pt
.RowAxisLayout xlTabularRow
.RepeatAllLabels xlRepeatLabels ' Add this line here
.PivotFields(1).Orientation = xlRowField
.PivotFields(5).Orientation = xlRowField
.PivotFields(6).Orientation = xlRowField
.PivotFields(8).Orientation = xlRowField
End With
Call PvtNoSubTtl
End Sub
Sub PvtNoSubTtl()
Dim pt As PivotTable
Dim pf As PivotField
On Error Resume Next
For Each pt In ActiveSheet.PivotTables
pt.RowAxisLayout xlTabularRow
Next pt
For Each pt In ActiveSheet.PivotTables
For Each pf In pt.PivotFields
pf.RepeatLabels = False
pf.Subtotals(1) = True
pf.Subtotals(1) = False
Next pf
Next pt
End Sub
Hope this helps
Cheers @sssim4567
hello
i’ve done
but it doesn’t work only this phase
.RepeatAllLabels xlRepeatLabels