PDA

View Full Version : Sheet Reference error



MrMoss
06-13-2014, 11:01 AM
Hello;

I am working on a macro that will generate monthly attendance reports for a call center. as part of that macro I am using the following code:




Dim y As Long
Dim D As Long
y = 16
sheetName = "April"



Dim Login_Available As PivotTable

Set Login_Available = Worksheets("Login_Available").PivotTables("PivotTable1")

For D = 2 To y - 1
'On Error Resume Next
Worksheets(sheetName).Cells(38, D) = Login_Available.GetPivotData("Average of First Available Time of Day (INT)", "Supervisor", Worksheets("Sheet2").Range("B2"), "Agent", Worksheets("Sheet2").Range("A4"), "Date", Worksheets(sheetName).Cells(3, D))


Next

This code is meant to pull data from a pivot table and past it in the the specified month (April). with the code as it is now I get an Application-defined or Object-defined error.

but if instead of pointing the code to past the data in April i direct it to my test sheet (test) it works just fine. any suggestions as to why this is happening?

Note: the on error resume next will be part of the code once i get this working so that the loop does not error out of it hits an error pulling from the pivot table.

westconn1
06-14-2014, 02:40 AM
try

Worksheets(sheetName).Cells(38, "D") =