Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
MarkersColor: wrong error behavior
Hi all,
As a requital I submit a macro that some of technical Excel user may find useful. A snag, however, appers on the place marked by the remarks. Error handling requests in this case obviously some other trick I know nothing of. Many thanks Petr Sub MarkerColor() 'Sub changes the colors of individual markers in the selected series 'of x-y chart into the colors of the fonts of parent cell v a l u e s. 'It keeps the marker interior the way as defined for the whole series: 'either empty, or–this time-of uniform color. If, however, the background 'of any value cell is light gray, the interior of corresponding 'marker changes into its opposite, i.e. if the series has been declared 'as marker full then such a marker turns to empty and vice versa. 'If the background is medium gray, the marker disappears. 'The aim is to identify individual markers or their groups within 'one complete series on a x-y chart, without having to decompose 'the parent range into subranges. Dim SP As Points, W As Range Dim ErrMsg As String, SPF As String, Rng As String Dim I As Long, N As Long, PosComma As Long, ICI As Long, FCI As Long Dim MarkerIsEmpty As Boolean Const LightGray = 15, MediumGray = 48 ErrMsg = "No series has been selected" On Error GoTo ErrExit Set SP = Selection.Points MarkerIsEmpty = Selection.MarkerBackgroundColorIndex = xlNone N = SP.Count SPF = SP.Parent.Formula I = 3 Do I = I + 1 Rng$ = Right(SPF, I) Loop Until Left(Rng, 1) = "!" Rng = Right(Rng, Len(Rng) - 1) PosComma = Application.WorksheetFunction.Search(",", Rng) Rng$ = Left$(Rng, PosComma - 1) Set W = Range(Rng) For I = 1 To N FCI = W.Cells(I).Font.ColorIndex On Error GoTo Skip 'Here, if the I-th marker is missing (one of co-ordinate 'cells is empty or it is outside x or y chart scales) an error should occure and such a marker should be skipped SP(I).MarkerForegroundColorIndex = FCI 'It works fine, but only once. If there are more such cases, the error 'appers invariably at the second of them as the collapse #1004 WHY? '("Can't set the property...) ICI = W.Cells(I).Interior.ColorIndex If ICI = LightGray Xor MarkerIsEmpty Then SP(I).MarkerBackgroundColorIndex = xlNone ElseIf ICI = MediumGray Then SP(I).MarkerForegroundColorIndex = xlNone SP(I).MarkerBackgroundColorIndex = xlNone Else SP(I).MarkerBackgroundColorIndex = FCI End If Skip: On Error GoTo 0 Next I Exit Sub ErrExit: MsgBox ErrMsg$ On Error GoTo 0 End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i add an error message if someone enters wrong data | Excel Discussion (Misc queries) | |||
Error Message :A value used in the formula is of the wrong data ty | Excel Worksheet Functions | |||
Wrong amount or calculation error? | Excel Discussion (Misc queries) | |||
Run time error 1004 - what have I done wrong? | Excel Discussion (Misc queries) | |||
How to get a cell to error if the wrong figue is entered | Excel Discussion (Misc queries) |