У меня есть сводная таблица на рабочем листе, и я хотел бы перебрать один из столбцов, найти соответствующую информацию и ввести значение переменной в 6 ячеек справа.Я не могу установить сводную таблицу.Я получаю «Ошибка времени выполнения« 438 »: объект не поддерживает это свойство или метод».Когда я комментирую эти строки кода, я получаю «Ошибка времени выполнения 91: переменная объекта или переменная блока не установлена».Что мне нужно сделать, чтобы установить сводную таблицу?
Option Explicit
Dim ProcRowCount As Integer
Dim Process As String
Dim ProcSID As String
Dim ProcStat As String
Dim ProcBeg As Date
Dim ScheRow As Integer
Dim ProcRow As Integer
Dim OffName As String
Dim DueDate As Date
Dim SchEvent As String
Dim EventSID As String
Dim EventRow As Integer
Dim Event2025 As String
Dim EventOut As String
Dim EventDate As Date
Dim Eventdate2 As Date
Dim NameSID As String
Dim Pivotitem As PivotItems
Dim Pivot As PivotTable
Dim Pivotfield As Pivotfield
Private Sub EventReview()
'Loop though 2025
With ThisWorkbook.Worksheets("2025")
ScheRow = 2 'Worksheets("2025").Cells(Rows.Count, "a").End(xlUp).Row
EventRow = 2
EventSID = Worksheets("2025").Cells(EventRow, "a")
ProcSID = "7777777"
OffName = "E Off"
Do While EventRow <= ScheRow
Event2025 = Worksheets("2025").Cells(EventRow, "j")
EventOut = Worksheets("2025").Cells(EventRow, "Q")
EventSID = Worksheets("2025").Cells(EventRow, "a")
If ProcSID = EventSID And Event2025 = SchEvent And (EventOut = "Occur" Or EventOut = "OccVio") Then
EventDate = Worksheets("2025").Cells(EventRow, "o")
If Eventdate2 = "12:00:00 AM" Or Eventdate2 < EventDate Then
Eventdate2 = EventDate
End If
EventRow = EventRow + 1
Else: EventRow = EventRow + 1
End If
Loop
End With
NameSID = OffName & " " & ProcSID
'loop through pivot table, insert date in offset column
With ThisWorkbook.Worksheets("Dashboard")
Set Pivot = Worksheets("Dashboard").PivotTable("ProcessPivot") ***Error happens here***
Set Pivotfield = Pivot.PivotFields("HelperColumn").PivotItems
For Each Pivotitem In Pivotfield.PivotItems
If Pivotitem = NameSID And Eventdate2 <> "12:00:00 AM" Then
Pivotitem.Offset(0, 6) = Eventdate2
ElseIf Pivotitem = NameSID Then
Pivotitem.Offset(0, 6) = "Not Reviewed"
End If
Next Pivotitem
End With
End Sub