首次发布。感谢所有回答的人。许多人从你们每个人那里学到了很多东西。
使用VBA创建数据透视表。想要值区域单元格(数据和标签); HorizontalAlignment = xlCenter。现行方法;
'... typical VBA code to create Pivot table;
'ActiveWorkbook.PivotCaches.Create ...
'Dim MyPT As PivotTable
'...
'number format all value cells (done without selecting)
MyPT.PivotFields("Sum of Bikes").NumberFormat = "#,##0.00"
'center align all value cells, data & lables (must select cells to do this)
Dim pvtField As PivotField
For Each pvtField In MyPT.PivotFields
If pvtField = "Bikes" Then
MyPT.PivotSelect "", xlDataAndLabel, True
'The PivotSelect method does not return an object. It selects a range.
Selection.HorizontalAlignment = xlCenter
End If
Next pvtField
如果没有通过PivotSelect选择范围(类似于数字格式的应用方式),是否可以这样做?