excel vba - Generated Data Label values from worksheet somtimes don't show -
i generating values in excel 2010, putting them array, copying them worksheet use datalabels logarithmix x-axis (actually calling chart labeller that, happens when manually apply through excel). part works fine without problems. in instances, however, some, not all, of data labels not visible show, though data in worksheet there, manually selecting data labels shows invisible label selected.
what found out, , think may bug in excel, when go worksheet, , re-type in value not showing on chart, shows on chart.
here dim's array:
dim chart_labeler_info_x() here how populate array:
'assuming going x-axis redim chart_labeler_info_x(1 x_axis_interval_num, 1 3) k = 1 x_axis_interval_num 'column 1 new chart label value, column 2 y value of new series , column 3 x value(equivalent 111...) '-------------------------------------------------------- chart_labeler_info_x(k, 1) = suf_ize(10 ^ (log(x_axis.minimumscale) / log(10#) + (k - 1))) chart_labeler_info_x(k, 2) = y_axis.minimumscale chart_labeler_info_x(k, 3) = 10 ^ (log(x_axis.minimumscale) / log(10#) + (k - 1)) '-------------------------------------------------------- next k here how initialize range on worksheet:
set new_labeler_ws_x_axis = sheets.add new_labeler_ws_x_axis.name = chart_for_series & "eng_labels_x_axis" new_labeler_ws_x_axis.range("a1:c" & x_axis_interval_num).value = chart_labeler_info_x new_labeler_ws_x_axis.range("a1:c" & x_axis_interval_num).font.name = "arial" new_labeler_ws_x_axis.range("a1:c" & x_axis_interval_num).font.size = 7 i create new series attached range:
with activechart.seriescollection.newseries .xvalues = sheets(new_labeler_ws_x_axis.name).range("c1:c" & x_axis_interval_num) .values = sheets(new_labeler_ws_x_axis.name).range("b1:b" & x_axis_interval_num) .name = "=""labeller_x""" .border.color = rgb(0, 0, 0) .format.line.visible = true end the data generated in worksheet looks this:
1m 100 0.001 10m 100 0.01 100m 100 0.1 1 100 1 10 100 10 100 100 100 1k 100 1000 column 1 has values used new data labels. column 2 y-value, column 3 actual x-value. (i can attache worksheet if helps.)
here image of talking about:

you notice 1k data label should there, not visible.
i can make 1k data label appear 1 of 2 ways:
- extend maximum value series, in case 10,000 (10k) in case 1k label shows.
- manually go worksheet, select cell has 1000 value, re-enter value 1000 , press return, data label shows 1k.
some other interesting anomalies, when maximum value 100, data label 100 disappears also. maximum value increased beyond 1000, there seems no problems data labels show themselves.
i have tried changing number format, general, number, 2 decimal places, no luck. changing text , back, no luck.
i think bug, haven't found in info, can of experts out there shine light on this?
thanks,
russ
i found solution, while of hack, think underlines problem may be, , maybe can suggest more elegant solution.
i added last line of code block:
chart_labeler_info_x(k, 1) = suf_ize(10 ^ (log(x_axis.minimumscale) / log(10#) + (k - 1))) chart_labeler_info_x(k, 2) = y_axis.minimumscale chart_labeler_info_x(k, 3) = 10# ^ (log(x_axis.minimumscale) / log(10#) + (k - 1#)) 'this line did trick if chart_labeler_info_x(k, 3) >= 1 chart_labeler_info_x(k, 3) = round(chart_labeler_info_x(k, 3), 0) as said previously, had found manually updating value in cell, caused labels visible. tried applying round function value in cell, , worked, put check in code, values of 1 , higher.
it appears that, though cell value shown 1000, internally, must not be. (i checked .value , .value2, both reported 1000.) bug think lies in happening sometimes. if maximum value of series increased, 1k label appears, though it same math being used generate values.
maybe can explain why happening , offer more elegant solution!
thanks,
russ
Comments
Post a Comment