(Solved) – VBA charts not refreshing with refresh.all or if I loop through the charts

(solved)-–-vba-charts-not-refreshing-with-refresh.all-or-if-i-loop-through-the-charts

Hello I am trying to write a script that will call a function to refresh charts every 30 seconds. The first function provided works by simply telling the machine to run my other function “RefreshCharts” after 30 seconds. The problem I am having in my RefreshCharts sub however is that the charts do not refresh when I run the script. First I just had a function that just had refresh.all in it but that wasn’t updating the charts even though when I recorded a macro in excel that’s what it gave me and it worked then but doesn’t when I update the data (the data is pulled from a separate sheet) right now I tried to loop through each chart in the workbook and tried to see if they would update if I wrote that they should refresh in the loop but still they don’t update. Below is the code I am using any help would be appreciated.

Sub myTime()

    Application.OnTime Now   TimeValue("00:00:30"), "RefreshCharts"


End Sub

Sub RefreshCharts()

    Workbooks.Open Filename:="C:Usersmansah57DesktopMalek Excelrefresh2019 EXCEL Filling Daily Production Tracking.xlsx"
    Dim myChart As ChartObject
    For Each myChart In ThisWorkbook.Charts
        myChart.Chart.Refresh
        'Debug.Print "hit"
    Next myChart
    Application.ScreenUpdating = True
    Workbooks("2019 EXCEL Filling Daily Production Tracking.xlsx").Close SaveChanges:=False
    Call myTime

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *