Chart Ranges

mikeymay

Well-known Member
Joined
Jan 17, 2006
Messages
1,600
Office Version
  1. 365
Platform
  1. Windows
I have multiple pie charts in a sheet that get updated via a dynamic range address.

When there is more than 1 row of data in the dynamic range, the chart renders as required
1664799483628.png


Sometimes when there is only 1 row of data in the dynamic range, the chart renders as below
1664799524342.png

When it should render using the range as below
1664799575793.png


The labels should show as
Contractor
0.01
100%

Now some of the charts that have only one row do actually render correctly.

I can manually fix this by using the 'Switch Row/Column' button when I click on the Select Data Source when i right click on the chart.

As the process to set the address for over 100 charts is execute via a macro, I can't manually check each chart and I don't know how to establish if a chart is showing incorrectly so i can add a line of code to do the Row/Column swap.


TIA
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
After a bit of digging I've come up with the following code which seems to fix the problem
VBA Code:
If intRows = 1 Then
   Set srsSeries = ActiveChart.FullSeriesCollection
   
   If IsEmpty(srsSeries.Item(1).XValues(1)) Then
      ActiveChart.PlotBy = xlColumns

      Else
   End If
   Else
End If
 
Upvote 0
Solution

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top