使用VBA过滤Powerpivot

时间:2015-04-27 20:47:59

标签: excel-vba powerpivot vba excel

好的,所以这个宏应该根据位于另一个工作表中的列表循环遍历枢轴的SUPPLIER FILTER。每次循环后,都必须以.pdf格式将文件上传到Intranet。

整个代码是:

Sub Adinn()
Dim i As Integer, n As Integer

Application.Calculation = xlCalculateManual

n = Application.WorksheetFunction.CountA(Worksheets("List").Range("A:A")) - 1


ReDim SUPPLIER(n - 1, 1) As String

For i = 1 To n
SUPPLIER(i - 1, 0) = Worksheets("List").Cells(1 + i, 1)
SUPPLIER(i - 1, 1) = Worksheets("List").Cells(1 + i, 2)
Next i

For i = 1 To n
Sheets("To Supplier").Select
ActiveSheet.PivotTables("PivotTable1").PageFields("[Query].[SUPPLIER].[SUPPLIER]").VisibleItemsList = _
"[Query].[SUPPLIER]." & SUPPLIER(i - 1, 0)

Sheets("To Supplier").Calculate

 Sheets("To Supplier").Select

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
    "http://enterpriseweb.com/portalone/sourcing/Supplier%20documents/" & SUPPLIER(i - 1, 1) _
    & "/Evaluations/" & SUPPLIER(i - 1, 1) & " Credits.pdf" _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False
On Error Resume Next

Next i

Application.Calculation = xlCalculationAutomatic

Sheets("Overview").Select

End Sub

我认为问题在于两者:

SUPPLIER(i - 1, 0) = Worksheets("List").Cells(1 + i, 1) 'Supplier Name
SUPPLIER(i - 1, 1) = Worksheets("List").Cells(1 + i, 2) 'Supplier Code

当我将它们作为PivotItem引入并将其连接到链接时。显然,应该出现的是代表的值。

0 个答案:

没有答案