私はVBAとこのグループにも新しく、愚かなクエリを求めている場合は私にご負担ください。 私はプロジェクトに請求されているメンバーの数を知るために、VBAプログラミングピボットテーブルを作成しようとしています。VBA Piovotテーブル - 複数のレポートフィルタの選択
私は
1(50K記録から)アカウントIDの100から1またはアカウントID "AI124", "AI245", "AI456", "AI671"
のような多くのことができるレポートフィルタに存在するアカウントIDを取得されます)私はフィルタリングすることはできませんよVBAを使用する複数のアカウントID。
2)チームのメンバーは、昨年からこのアカウントIDに主張していただろうが、私は、私はインターネットでチェックしてみました
値をヘッダーに指定される月の11日から移入する必要があり、以下の書き始め正確ではないかもしれないが、参照として提供するコード。
Sub CreatePivot()
' Creates a PivotTable report from the table on Sheet1
' by using the PivotTableWizard method with the PivotFields
' method to specify the fields in the PivotTable.
Dim objTable As PivotTable, objField As PivotField
' Select the sheet and first cell of the table that contains the data.
ActiveWorkbook.Sheets("DATA").Select
Range("A1").Select
' Create the PivotTable object based on the Employee data on Sheet1.
Set objTable = Sheet1.PivotTableWizard
' Specify row and column fields.
Set objField = objTable.PivotFields("Emp Last Name")
objField.Orientation = xlRowField
objField.Position = 1
Set objField = objTable.PivotFields("Emp Ser Num")
objField.Orientation = xlRowField
objField.Position = 2
Set objField = objTable.PivotFields("Week Ending Date")
objField.Orientation = xlColumnField
objField.Position = 1
' Specify a data field with its summary
' function and format.
Set objField = objTable.PivotFields("Total Hrs Expended")
objField.Orientation = xlDataField
objField.Function = xlSum
objField.NumberFormat = "#,##0"
' Specify a page field.
Set objField = objTable.PivotFields("Account Id")
objField.Orientation = xlPageField
Application.ScreenUpdating = False
'ActiveSheet.PivotTables("PivotTable2").ManualUpdate = True
objTable.ManualUpdate = True
'objTable.PivotFields("Account Id").ClearAllFilters
' objTable.PivotFields("Account Id").CurrentPage = Array("PJ1234", _ "AI82159", "AI5444")
'-------------
Set objField = objTable.PivotFields("Account Id")
objField.Orientation = xlPageField
Myarray = Array("PJ1234", "AI5444", "AI82159")
For x = 1 To objField.PivotFields.Count
objField.PivotFields(x).Visible = False
Next
For x = 0 To 3
objField.PivotFields(Myarray(x)).Visible = True
Next
objTable.ManualUpdate = False
Application.ScreenUpdating = True
' Preview the new PivotTable report.
ActiveSheet.PrintPreview
' Prompt the user whether to delete the PivotTable.
Application.DisplayAlerts = False
If MsgBox("Delete the PivotTable?", vbYesNo) = vbYes Then
ActiveSheet.Delete
End If
Application.DisplayAlerts = True
End Sub
ご協力いただき誠にありがとうございます。
ようこそ。あなたは本当に質問していません。あなたのコードを試しましたか?エラーが発生しましたか?何が起こると予想され、どの部分が期待どおりに動かなかったのですか? – OldUgly
投稿する[MCVE] –
こんにちはOldUgly、ありがとうございます。私の質問は、複数のアカウントIDをレポートフィルタの一部として選択するVBAプログラムを作成する方法です。私のコードを参考にしました。ありがとうございました。また、エラーはなく、Myarrayに追加しようとすると、最初のアカウントIDの詳細が複数のアカウントID –