问题
If I'm dealing with hundreds of graphs, which are right now automatically setting the y axis, how can I eliminate 10.0%, 20.0%, and make it simply 10%, 20% (a savings of 2 characters)? I'm using Excel 2010, and don't want to mess up automatic formatting since there may be times that I need the percent decimal places, as in unemployment (4.5% is meaningful). Of course, sometimes I graph stuff on the y axis in millions or billions of dollars (but that's a separate question).
Update: I found out that security rules prohibit macros in spreadsheets. Can it be done without macros, by setting a value? Perhaps that is something that the vendor (Microsoft) would do in future years....
回答1:
Right click the Y Axis you want to change. Go to "Format Axis", and click "Number". Here is where you can choose what type (accounting, number, percentage, etc) of formatting you want. Just choose "Percentage" and put "0" for the "Decimal Places".
Macro which will do so for all charts in a worksheet:
Sub Macro2()
Dim obj As Object
For Each obj In ActiveSheet.ChartObjects
With obj.Chart.Axes(xlValue)
.TickLabels.NumberFormat = "0%"
End With
Next obj
End Sub
来源:https://stackoverflow.com/questions/32459870/decimal-places-on-hundreds-of-excel-graphs