FWIW, cleanup up the macro to
a. make it easier for me to follow
b. avoid assuming which the active sheet
c. no selecting things
and didn't really have any problems with the logic
Option Explicit
Sub Macro2()
Dim pt As PivotTable
Application.ScreenUpdating = False
Worksheets.Add.Name = "days_count"
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:="ResUsage!R1C2:R1048576C2", Version:=6).CreatePivotTable _
TableDestination:="days_count!R3C1", TableName:="PivotTable2", DefaultVersion:=6
Set pt = Worksheets("days_count").PivotTables(1)
With pt
.ColumnGrand = True
.HasAutoFormat = True
.DisplayErrorString = False
.DisplayNullString = True
.EnableDrilldown = True
.ErrorString = ""
.MergeLabels = False
.NullString = ""
.PageFieldOrder = 2
.PageFieldWrapCount = 0
.PreserveFormatting = True
.RowGrand = True
.SaveData = True
.PrintTitles = False
.RepeatItemsOnEachPrintedPage = True
.TotalsAnnotation = False
.CompactRowIndent = 1
.InGridDropZones = False
.DisplayFieldCaptions = True
.DisplayMemberPropertyTooltips = False
.DisplayContextTooltips = True
.ShowDrillIndicators = True
.PrintDrillIndicators = False
.AllowMultipleFilters = False
.SortUsingCustomLists = True
.FieldListSortAscending = False
.ShowValuesRow = False
.CalculatedMembersInFilters = False
.RowAxisLayout xlCompactRow
With .PivotCache
.RefreshOnFileOpen = False
.MissingItemsLimit = xlMissingItemsDefault
End With
.RepeatAllLabels xlRepeatLabels
.AddDataField .PivotFields("LogDate"), "Count of LogDate", xlCount
With .PivotFields("LogDate")
.Orientation = xlRowField
.Position = 1
End With
End With
ActiveWorkbook.ShowPivotTableFieldList = True
With Worksheets("days_count")
.Shapes.AddChart2(227, xlLine).Select
ActiveChart.SetSourceData Source:=Range("days_count!$A$3:$B$12")
ActiveChart.Parent.Cut
End With
With Worksheets("ResUsage")
.Select
.Range("F1").Select ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.Pictures.Paste
End With
Application.DisplayAlerts = False 'switching off the alert button
Worksheets("days_count").Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub