The macro snippet below is a tried and true one I've been using for months. This morning it started giving me an error 13 Type Mismatch on the line beginning "ActiveWorkbook.PivotCaches.Add...". I thought maybe it was having trouble with the used range, so tried adding "ActiveSheet.UsedRange
", but that didn't help. I'd appreciate any insight anyone can provide.
Sub View3nhlf()
    Dim LastRow As Long
    Dim pt As PivotTable, pi As PivotItem
    'This macro creates the Pivot and the View3nhlf sheet from the Detail sheet
    Dim ws As Worksheet
    Set ws = Sheets("Detail")

    With Application    'code below speeds up operation
        .ScreenUpdating = False
        .EnableEvents = False

        ws.Activate
        ActiveSheet.UsedRange
        'Create the pivot
        Cells.Select
        ActiveWorkbook.PivotCaches.Add(SourceType:=xlDatabase, SourceData:= _
                                       ActiveSheet.UsedRange).CreatePivotTable TableDestination:="", TableName:= _
                                       "PivotTable1", DefaultVersion:=xlPivotTableVersion10
        ActiveSheet.PivotTableWizard TableDestination:=ActiveSheet.Cells(3, 1)

        'Define a name for our pivot table
        Set pt = ActiveSheet.PivotTables("PivotTable1")

        'Stop the pivot from updating itself
        pt.ManualUpdate = True