Consulting

Results 1 to 2 of 2

Thread: Sheet Reference error

  1. #1
    VBAX Newbie
    Joined
    Jun 2014
    Posts
    1
    Location

    Sheet Reference error

    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.

  2. #2
    try
    Worksheets(sheetName).Cells(38, "D") =

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •