error 1004

sheshe123

New Member
Joined
Sep 24, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi not sure what I'm doing but I'm trying to help my mom she's using someone's weekly giving software and its giving me ; error 1004 unable to get the pivittables property of the worksheet class.
we've tried to start over multiple times with the same result, i know nothing about code but i know somethings wrong, i see others answers but am not knowledgeable to know how it applies to my situation. any help is appreciated. below is a copy of the section of code getting the error.


VBA Code:
Sub RefreshPivotTables()
Dim NumRows, RowToPaste, NR_Row, PT_Row  As Long
Dim PT As PivotTable

    'Refresh Giving Summary Pivot Table
    Entry.Activate
   
   
   
   
    Set PT = ActiveSheet.PivotTables("PT_Specials")
   
   
        
        
   
    PT.RefreshTable
    PT_Row = PT.TableRange1.Rows(PT.TableRange1.Rows.Count).Row
    NR_Row = Range("Print_GivingSummary").Row + Range("Print_GivingSummary").Rows.Count - 1
    With Range("Print_GivingSummary")
    .Resize(.Rows.Count + PT_Row - NR_Row, .Columns.Count).Name = "Print_GivingSummary"
    End With
    ActiveSheet.PageSetup.PrintArea = Range("Print_GivingSummary").Address
    Columns("B:B").EntireColumn.AutoFit

    'Refresh Report Pivot Table
    Annual.Activate
    RowToPaste = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row + 1
    NR_Row = Range("AnnualSpecials").Row + Range("AnnualSpecials").Rows.Count - 1
    With Range("AnnualSpecials")
    .Resize(.Rows.Count + RowToPaste - NR_Row, .Columns.Count).Name = "AnnualSpecials"
    End With
   
    Reports.Activate
    Set PT = ActiveSheet.PivotTables("PT_RptSpecials")
    PT.RefreshTable
    PT_Row = PT.TableRange1.Rows(PT.TableRange1.Rows.Count).Row
    NR_Row = Range("Print_Report").Row + Range("Print_Report").Rows.Count - 1
    With Range("Print_Report")
    .Resize(.Rows.Count + PT_Row - NR_Row, .Columns.Count).Name = "Print_Report"
    End With
    ActiveSheet.PageSetup.PrintArea = Range("Print_Report").Address
    Columns("B:B").EntireColumn.AutoFit

    Entry.Activate
    Set PT = Nothing

End Sub
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,576
Hi sheshe 123 and Welcome to the Board. Trial explicitly declaring all of your variables. When U Dim...
Code:
Dim NumRows, RowToPaste, NR_Row, PT_Row  As Long
only the PT_Row is long and the rest are Variant variables and XL just does whatever it wants. ie......
Code:
Dim  NumRows As Long, RowToPast As Long, NR_Row As Long, PT_Row  As Long
HTH. Dave
 

sheshe123

New Member
Joined
Sep 24, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Hi sheshe 123 and Welcome to the Board. Trial explicitly declaring all of your variables. When U Dim...
Code:
Dim NumRows, RowToPaste, NR_Row, PT_Row  As Long
only the PT_Row is long and the rest are Variant variables and XL just does whatever it wants. ie......
Code:
Dim  NumRows As Long, RowToPast As Long, NR_Row As Long, PT_Row  As Long
HTH. Dave
hi again. the issue resolved itself on the original file it saves and works just great. however when i try to save it to a usb then apply it to a shared computer i get the error again.
or I get active workbook .SAVECOPYAS strgivingFileName.
I don't know anything about actual coding but the goal is to take the completed file and move it to a different computer .
 

Watch MrExcel Video

Forum statistics

Threads
1,114,362
Messages
5,547,473
Members
410,797
Latest member
mlfuson
Top