VBA-Edited Excel charts are rendering as blank squares until interacted with

51 Views Asked by At

I have workbook with a number of worksheets titled " Plots". Each " Plots" sheet has multiple line charts. These sheets are usually hidden. I run a VBA code that:

  1. Sets ScreenUpdating = False
  2. Unhides all of the sheets with the " Plots" titles.
  3. Runs .Chart.ChartArea.ClearContents on each chart
  4. Loops through each chart in to apply some formatting to the axes
  5. Loops through each chart to add several series, setting the Name, Values, and line format for each one.
  6. Sets ScreenUpdating = True This leaves all of the " Plots" sheets visible for review.

The problem is, every time I do this, some charts render as white squares: Chart failing to render

Which charts do this changes each time the VBA script runs. I would estimate that it averages at 1/3 of all charts being blank, though sometimes in sheets with more charts over 1/2 are blank. Clicking on the area selects the invisible chart elements, making the selection indicators (the circles around a selected element) visible but not the element itself. Everything is there, but not rendering. Moving the chart or editing any element of the chart makes it immediately render.

Has anyone encountered this problem before? Is there a solution other than manually moving each affected chart and then undoing the movement?

  • Office 365
  • Windows 10 Enterprise on an HP EliteBook 840 G5
  • 16gb RAM
  • This problem persists through computer resets
  • This problem occurs on coworker's computers as well
  • This problem occurs on multiple workbooks which share most of the same code
  • Copying a sheet to a new workbook causes all plots to be visible on the new workbook, even if they have not been interacted with. The problem charts still won't be rendered in the original workbook.
  • Adding lines to nudge the charts with Shape.IncrementLeft during the VBA script does not fix the problem, even though manually nudging the charts after the script completes does fix the problem.
0

There are 0 best solutions below