在谁能告诉我这段代码中的透视表引用错在哪? Public Sub 查找机型日期() Dim czb, dt As Worksheet Dim rq, DA As Date Dim jx, dq As variant Dim I, J As Long
Set czb = ThisWorkbook.Worksheets("底价变动") Set dt = ThisWorkbook.Worksheets("DT(2)") dt.Activate ActiveSheet.Range("A2").Select ActiveCell.CurrentRegion.Select
For I = 2 To Selection.Rows.Count Set jx = dt.Cells(I, 3) Set dq = dt.Cells(I, 1) czb.Activate ActiveSheet.Range("A2").Select ActiveCell.CurrentRegion.Select
For J = Selection.Rows.Count To 2 Step -1 If Cells(J, 2).Value Like jx And Cells(J, 3).Value Like dq Then Set rq = Cells(J, 1).Value End If Exit For Next With dt If Cells(I, 10).Formula = "" And Cells(I, 11).Formula = "" Then .Cells(I, 10).Value = _ Worksheets("Pro_变动").PivotTable.GetPivotData("客提货底价", Pro_变动!R3C1, "开始日期", rq, "机型", jx, "地区", dq) .Cells(I, 11).Value = _ Worksheets("Pro_变动").PivotTable.GetPivotData("客提货标价", Pro_变动!R3C1, "开始日期", rq, "机型", jx, "地区", dq) End If End With Next End Sub
程序执行到下面这段时停止,错误提示"要求对象",我想可能是因为在VB中引用透视表中数据的方法有误,谁能告诉我怎么改?
.Cells(I, 10).Value = _ Worksheets("Pro_变动").PivotTable.GetPivotData("客提货底价", Pro_变动!R3C1, "开始日期", rq, "机型", jx, "地区", dq) .Cells(I, 11).Value = _ Worksheets("Pro_变动").PivotTable.GetPivotData("客提货标价", Pro_变动!R3C1, "开始日期", rq, "机型", jx, "地区", dq)
|