Charts Labels sizes VBA

barnesjr

New Member
Joined
Jan 28, 2006
Messages
3
I have been experimenting with VBA generation of XY scatter chart based on a listing made by the user. The Chart is totally created, modified, etc using VBA. During the course of creating this code and worksheet, I observed the following and I was wondering if anyone has made similar observations. (Excel97, used on Win98SE and WinXP)

1) Chart Label sizing>
As is known there is NO method to alter (or obtain) label box sizing (Width or Height), BUT - from testing it appears that the label's max <available> width is determined by the ChartArea width setting. The label will display the (label) contents to this maximum width and then will commence wrapping the contents onto the next line/s. If the contents do not require the max width, the box will shrink. (Legend width does NOT appear dependent on PlotArea width setting.) Label box height is determined by Font size selected.

2) Chart Label>
Using VBA to define the label contents by setting ....Text = "?????"

Directly entering a value via code as ...Text = "123.4"
The Label Text will be considered a number, even if the code first sets NumberFormat = "@" (i.e. Text)

The same occurs if the code References a cell, such as ...Text = Cells(5,3). Contents will be taken as being a number, even if the cell's contents has been preformatted as "Text" and testing the cell using isnumber(cell) = False

In all cases, when the specific label is clicked upon, and the label format window is opened, the <number> category will always appear as "general"

3) Chart Label formatting - adding the comma to numbers>
When using VBA to define specific labels, setting ...NumberFormat = "#,###.0" or "#,###.#" does not act as supposed. The label will show the contents as #,###.#0. And when the value is ####.12, the label will still show as #,###.10

The same occurs when .NumberFormat is not set or ="@" and VBA sets the label by ...Text = format(value,"#,###.0")

But, the format #,### works if you do not need the 1st decimal
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.

Forum statistics

Threads
1,224,872
Messages
6,181,499
Members
453,047
Latest member
charlie_odd

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