Auto format a chart data label

Pauljj

Well-known Member
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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a \$25,000 loan, 5% annual interest, 60 month loan.

GraH

Well-known Member
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.

Replies
2
Views
2K
Replies
1
Views
370
Replies
2
Views
666
Replies
1
Views
2K
Replies
1
Views
350

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,151,957
Messages
5,767,308
Members
425,403
Latest member
MellieD

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.

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

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