Consulting

Results 1 to 2 of 2

Thread: run time error 1004 in pivot table wizard

  1. #1
    VBAX Regular
    Joined
    Jul 2015
    Posts
    32
    Location

    run time error 1004 in pivot table wizard

    Hi,

    When I run a macro, am getting run time error message 1004 in the pivot table wizard as I found only header with data.

    if there are no data to put a pivot the results should be displayed as "No results" by inserting a new worksheet.

    Below is the code where I get an error message.

    Dim objTable As PivotTable, objField As PivotField
        ActiveWorkbook.Sheets("Sheet1").Select
        Range("A1").Select
       
        Set objTable = Sheets("Sheet1").PivotTableWizard  'Mscro stops here with the error message
     
        With Application
            .ScreenUpdating = False
            .EnableEvents = False
            .Calculation = CalcMode
        End With
    -Tharabai

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    Long shot, but perhaps something like:
    Dim objTable As PivotTable, objField As PivotField
    ActiveWorkbook.Sheets("Sheet1").Select
    
    If Range("A1").CurrentRegion.Rows.Count > 1 Then
      Range("A1").Select
      Set objTable = Sheets("Sheet1").PivotTableWizard  'Mscro stops here with the error message
    Else
      Set NewSht = Sheets.Add  '(After:=Sheets(Sheets.Count))
      NewSht.Range("A1").Value = "No Results"
    End If
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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