Auto format a chart data label

Pauljj

Well-known Member
Joined
Mar 28, 2004
Messages
2,044
Morning all, I have a column chart that I have added data labels to

The chart can display 3 different types of data, depending on what the user chooses from the drop down menu

The data can be a percentage but if changed can be a whole number

So what I am trying to achieve is, when the user selects "Bookings" from the drop down option then SeriesCollection(2) formats the datalabel to "0%" otherwise the label should be formatted to "0,0"

The drop down is located in cell ref D11

My guess was to write some code in the sheet, create a Worksheet_Change(ByVal Target as Range)

Then say if D11 = "Bookings then

format the datalabel to % otherwise 0 but whilst this may be the right path my efforts for writing it have gone awry as I am getting a runtime error.

Any help would be much appreciated

Thanks
Paul
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off

GraH

Well-known Member
Joined
Mar 22, 2020
Messages
1,020
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have no clue how your data looks like, but something like this might work?
Book1
BCDE
2Series#%Labels
3SA6530%30%
4SB2215%15%
5SC9271%71%
6SD37100%100%
Sheet1
Cell Formulas
RangeFormula
D3:D6D3=C3/SUM(C3:C6)
E3:E6E3=IF($G$1="%",TEXT(D3,"0%"),TEXT(C3,"0"))


Depending on your Excel version, you can link labels to a value from cells. Else you need to link them one by one, by selecting the label, then entering ="CellRef" in the formulabar.
1634388608179.png


1634388625546.png
 

Forum statistics

Threads
1,147,498
Messages
5,741,504
Members
423,663
Latest member
kaveh87rsh

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
Top