excel - 您能否帮助在 Pivot 中使用过滤后的名称创建工作簿
问题描述
这是创建带有两个过滤器的数据透视表,第一个过滤器是名称,第二个过滤器是日期,所以当我们在第二个过滤器中选择最新日期时,它需要使用所有过滤器名称创建单独的工作簿,我尝试使用此代码
'''Sub arcpivot3()
Dim myPivotField As PivotField
Dim filterValue As String
Dim vendorname As String
Dim myString As String
Dim fp As Worksheet
Dim vr As Worksheet
Dim temp, ALastRow, BLastRow As Integer
Dim VendorNamesArray(100) As String
Set fp = Worksheets("2nd Pivot")
ALastRow = fp.Range("A" & Rows.Count).End(xlUp).Row
Dim ws As Worksheet
Set ws = Worksheets("secondpivot")
Dim pT As PivotTable
Set pT = ws.PivotTables("secondpivot_table")
Dim pF As PivotField
Set pF = pT.PivotFields("Principal Vendor Name")
pF.EnableMultiplePageItems = True
pF.CurrentPage = "(All)"
For i = 1 To pF.PivotItems.Count
If i < pF.PivotItems.Count Then
pF.PivotItems(i).Visible = False
Else
pF.PivotItems(i).Visible = True
End If
Next i
End With
a = ThisWorkbook.Worksheets.Count
For i = 1 To a
If ThisWorkbook.Worksheets(i).Name <> "vendor" Then
Set wb = Workbooks.Add
ThisWorkbook.Worksheets(i).Copy before:=wb.Worksheets(1)
If (VendorNamesArray(i) <> "") Then
wb.SaveAs "E:\ARC Attachments\" & groupname & "-" & reqid & "\" & VendorNamesArray(i) & ".xlsx"
wb.Close savechanges = True
Else
wb.SaveAs "E:\ARC Attachments\" & groupname & "-" & reqid & "\" & ActiveSheet.Name & ".xlsx"
wb.Close savechanges = True
End If
End If
Next i
End Sub'''
错误是它正在创建工作簿但不像expexted
解决方案
推荐阅读
- python - 无法在 text_box 小部件内放置文本
- python - 如何在@github.com 之前删除敏感信息以使用 Python 3.9 和/或正则表达式对其进行正确清理?
- laravel - 无法使用 BlueHost 中的 cron 作业在 Laravel 8 中运行任务计划
- python - 如何在不要求用户输入任何内容的情况下让我的计算器代码重复?- Python中的连续计算
- python - 字符串内容实际上是字节
- python-3.x - 无法通过 EC2 连接到网络驱动器
- python - 无法理解为什么我的程序中的一行会影响整体输出
- api - 允许使用放大身份验证在 graphql 模型中更新特定字段
- ios - “某些视图”类型的值没有成员“徽章”
- android - 各种android下使用maven测试java库