LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Overlapping DataLabels

I have to fix one problem, overlapping DataLabels. Each DataLabel can
have one of two possible colors. Each orange DataLabel must be on top,
and light orange below. I'm talking about depth, not a label position
around point.

How can I do that? Here is a source code:

' add lables to the peak info ranges (if they exist)
For pRangeCounter = pRangeFirstPeak To pRangeLastPeak Step 1

pNumberOfPeakValues =
CInt(Worksheets(pDataSheetName).Cells(pDataRowPeak Indicator,
pColumnCounter).Value)

If pNumberOfPeakValues = CInt(CVErr(xlErrNA)) Then
' do nothing
ElseIf pNumberOfPeakValues 0 Then
' range exist

' select range and add labels
ActiveChart.SeriesCollection(pRangeCounter).Select
ActiveChart.SeriesCollection(pRangeCounter).ApplyD ataLabels
Type:= _
xlDataLabelsShowLabel, AutoText:=True, LegendKey:=False

' go through points
For pPointCounter = 1 To REPORTED_DAYS Step 1

' row lies 1 row further then point number
pDataRow = pPointCounter + 1

' convert data value to numeric
pPeak = CDbl(Worksheets(pDataSheetName).Cells(pDataRow,
pColumnCounter).Value)

If pPeak = CDbl(CVErr(xlErrNA)) Then
' do nothing, skip this cell containing #NV
ElseIf pPeak 0 Then
' we found a peak
' select label and get info from datasheet

ActiveChart.SeriesCollection(pRangeCounter).Points (pPointCounter).DataLabel.Select

'define formula
pFormula = "=" & pDataSheetName & "!R" & pDataRow &
"C" & pColumnCounter + 1

Selection.Text = pFormula

' put label above
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Position = xlLabelPositionAbove
.Orientation = xlHorizontal
End With

If CInt(Worksheets(pDataSheetName).Cells(pDataRow,
pSlaColumn).Value) = pSlaKpi Then
' peak lies within the SLA month
pLabelColor = COLOR_ORANGE
Else
' peak lies not within the SLA month
pLabelColor = COLOR_LIGTH_ORANGE
End If
' color the label
With Selection.Border
.Weight = xlHairline
.LineStyle = xlNone
End With
Selection.Shadow = False
With Selection.Interior
.ColorIndex = pLabelColor
.PatternColorIndex = 1
.Pattern = xlSolid
End With

End If

Next pPointCounter

' select datalabels of current range

ActiveChart.SeriesCollection(pRangeCounter).DataLa bels.Select

' set font datalabels of current range
Selection.AutoScaleFont = True
With Selection.Font
.Bold = True
.Name = gFontName
.Size = FONT_SIZE_DATA_LABELS
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With

End If

pColumnCounter = pColumnCounter + pStepDataColumnPeak

Next pRangeCounter

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chart Datalabels.Position Michael Singmin Excel Programming 4 November 12th 05 07:12 PM
How to prevent datalabels overlaping each other? Cool Sport Excel Programming 1 September 26th 05 10:31 PM
Excel Chart Datalabels Sean Howard Excel Programming 6 April 20th 04 12:04 AM
Datalabels on Scatter Daniel Bonallack[_2_] Excel Programming 1 September 15th 03 10:23 PM
Converting DataLabels to Numbers Dan Gesshel Excel Programming 1 August 1st 03 04:34 AM


All times are GMT +1. The time now is 06:52 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"