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: 9
Default 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
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
how do i add an error message if someone enters wrong data Mike Excel Discussion (Misc queries) 3 September 29th 09 03:30 PM
Error Message :A value used in the formula is of the wrong data ty Graham Excel Worksheet Functions 4 June 16th 09 03:51 PM
Wrong amount or calculation error? Owen[_2_] Excel Discussion (Misc queries) 1 April 11th 07 06:45 PM
Run time error 1004 - what have I done wrong? alexwren Excel Discussion (Misc queries) 1 July 26th 06 01:42 AM
How to get a cell to error if the wrong figue is entered Eintsein_mc2 Excel Discussion (Misc queries) 4 September 14th 05 03:32 AM


All times are GMT +1. The time now is 08:29 AM.

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

About Us

"It's about Microsoft Excel"