各位老师: 附件是本人所写的用inputbox函数筛选数据透视表的代码, 但蓝色粗字部份出现1004错误, 请老师指点代码应如何更改? Private Sub 查询批号4() Dim box As String, arr() As String Dim i As Integer, r As Integer, n As Integer box = InputBox("请输入要查询的批号") If box = "" Then Exit Sub Application.ScreenUpdating = False Sheets("生产进度总表").Activate r = 0 With Sheets("生产进度总表").PivotTables("数据透视表1").PivotFields("批号") n = .pivotitems.Count For i = 1 To n If .pivotitems(i).Name <> box Then r = r + 1 ReDim Preserve arr(1 To r) As String arr(r) = .pivotitems(i).Name End If Next .pivotitems(box).Visible = True .pivotitems(arr).Visible = False End With Application.ScreenUpdating = True End Sub 谢谢
nrvv8tjl.rar
(36.81 KB, 下载次数: 11)
|