+ Reply to Thread
Results 1 to 2 of 2

Reference Open Workheet from Add-in VBA code

Hybrid View

  1. #1
    Registered User
    Join Date
    09-25-2012
    Location
    N. America
    MS-Off Ver
    Excel 2003
    Posts
    4

    Reference Open Workheet from Add-in VBA code

    I have a VBA code in an Excel add-in that is suppose to create a pivot table.
    How do I reference the worksheet I have opened from the Excel add-in vba code?
    I get an error when I execute the line: Set objTable = Sheet1.PivotTableWizard > Run-time error '1004' Application-defined

    'Dim objTable As PivotTable, objField As PivotField
    
    ActiveWorkbook.Sheets("logs").Select
    Range("A3:AN6").Select
    
    '****** Run-time error '1004' Application-defined or object defined error at line below
    Set objTable = Sheet1.PivotTableWizard
    
    Set objField = objTable.PivotFields("Type")
    objField.Orientation = xlRowField
    
    Set objField = objTable.PivotFields("Size")
    objField.Orientation = xlColumnField
    Last edited by Leith Ross; 09-25-2012 at 07:03 PM. Reason: Added Code Tags

  2. #2
    Registered User
    Join Date
    09-25-2012
    Location
    N. America
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Reference Open Workheet from Add-in VBA code

    change Sheet1. to ActiveWorkbook.ActiveSheet

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1