Sub Main()
Dim pvt As PivotTable
Dim fld As PivotField
Dim itm As PivotItem
Dim m As Variant
Set pvt = Worksheets(1).PivotTables(1)
Set fld = pvt.PageFields(1)
m = fld.PivotItems(1)
For Each itm In fld.PivotItems
If itm.Value > m Then m = itm.Value
Next itm
fld.CurrentPage = m
End Sub
0
您是否只想在动态创建图表后选择单元格?
就像是:
Dim value As Date
value = "1-apr-09"
Dim row As Integer
row = 0
Dim keeplooping As Boolean
keeplooping = True
While (keeplooping)
row = row + 1
If Range("B" & row).value = value Then
keeplooping = False
Range("B" & row).Select
MsgBox ("found it")
ElseIf Range("B" & row).value = "" Then
keeplooping = False
MsgBox ("Not found")
End If
Wend
3 回答
你不能遍历该页面的所有项目吗?这是一个数据透视表,但让它适用于图表应该不是什么大不了的事:
您是否只想在动态创建图表后选择单元格?
就像是:
chartObject.PivotLayout.PivotTable.PivotFields(“fieldName ").CurrentPage = " fieldValue”
这是来自Excel 2003,但我认为2002年将是类似的