Excel 2007 chart color change based on the label.

I have 12 charts 1 for each person and the data changes every week and
some of the values have 0 so are filtered out.  On the chart I want
0-15 to be blue, 16-30 to be light purple, 31-60 to be a cream color,
61-90 to be light blue, and 90+ to be dark purple.  With the code
below I can change the color if I take the if statement out but I
would like to change the color based on the label.  I have tried
several things like .text, .name, and .label.  I just can't fine the
right name.
	Name1
0-15	1
61-90	1
90+	3

                Name 2
0-15	14
16-30	5
31-60	1
61-90	6
90+	12




For i = 1 To ActiveChart.Legend.LegendEntries.Count
         ActiveChart.Legend.LegendEntries(i).LegendKey.Select
         If ActiveChart.Legend.LegendEntries(i).Label.Text = "0-15"
Then
             With Selection.Interior
             ActiveChart.Legend.LegendEntries(i).LegendKey
                 .ColorIndex = 60
             End With
         End If
         If ActiveChart.Legend.LegendEntries(i).Name = "16-30" Then
             With Selection.Interior
                 .ColorIndex = 2
             End With
         End If
         If ActiveChart.Legend.LegendEntries(i).Name = "31-60" Then
             With Selection.Interior
                 .ColorIndex = 3
             End With
         End If
         If ActiveChart.Legend.LegendEntries(i).Name = "61-90" Then
             With Selection.Interior
                 .ColorIndex = 4
             End With
         End If
         If ActiveChart.Legend.LegendEntries(i).Name = "90+" Then
             With Selection.Interior
                 .ColorIndex = 5
             End With
         End If
     Next i
0
frogman71 (34)
4/23/2008 6:23:47 PM
excel 39879 articles. 2 followers. Follow

1 Replies
713 Views

Similar Articles

[PageSpeed] 12

On Apr 23, 11:23=A0am, frogman7 <frogm...@googlemail.com> wrote:
> I have 12 charts 1 for each person and the data changes every week and
> some of the values have 0 so are filtered out. =A0On the chart I want
> 0-15 to be blue, 16-30 to be light purple, 31-60 to be a cream color,
> 61-90 to be light blue, and 90+ to be dark purple. =A0With the code
> below I can change the color if I take the if statement out but I
> would like to change the color based on the label. =A0I have tried
> several things like .text, .name, and .label. =A0I just can't fine the
> right name.
> =A0 =A0 =A0 =A0 Name1
> 0-15 =A0 =A01
> 61-90 =A0 1
> 90+ =A0 =A0 3
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 Name 2
> 0-15 =A0 =A014
> 16-30 =A0 5
> 31-60 =A0 1
> 61-90 =A0 6
> 90+ =A0 =A0 12
>
> For i =3D 1 To ActiveChart.Legend.LegendEntries.Count
> =A0 =A0 =A0 =A0 =A0ActiveChart.Legend.LegendEntries(i).LegendKey.Select
> =A0 =A0 =A0 =A0 =A0If ActiveChart.Legend.LegendEntries(i).Label.Text =3D "=
0-15"
> Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0With Selection.Interior
> =A0 =A0 =A0 =A0 =A0 =A0 =A0ActiveChart.Legend.LegendEntries(i).LegendKey
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.ColorIndex =3D 60
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0If ActiveChart.Legend.LegendEntries(i).Name =3D "16-30"=
 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0With Selection.Interior
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.ColorIndex =3D 2
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0If ActiveChart.Legend.LegendEntries(i).Name =3D "31-60"=
 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0With Selection.Interior
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.ColorIndex =3D 3
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0If ActiveChart.Legend.LegendEntries(i).Name =3D "61-90"=
 Then
> =A0 =A0 =A0 =A0 =A0 =A0 =A0With Selection.Interior
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.ColorIndex =3D 4
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0 =A0 =A0If ActiveChart.Legend.LegendEntries(i).Name =3D "90+" T=
hen
> =A0 =A0 =A0 =A0 =A0 =A0 =A0With Selection.Interior
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0.ColorIndex =3D 5
> =A0 =A0 =A0 =A0 =A0 =A0 =A0End With
> =A0 =A0 =A0 =A0 =A0End If
> =A0 =A0 =A0Next i

Is there any help on this.  Even if someone says that it can't be done
at least that will let me know to move on.  I have the code to just go
through and assign colort to each legend entry but when I filter out
the 0 values then the colors change based on position.  the 3rd legend
entry is changed to color 19.

Dim i As Integer
Dim j As Integer

    'loop through all the charts then through all the legends to
change color
    Application.Sheets("Individual Aging By Tech").Activate

    For j =3D 1 To ActiveSheet.ChartObjects.Count
    ActiveSheet.ChartObjects(j).Activate

    'loop through legend entries
     For i =3D 1 To ActiveChart.Legend.LegendEntries.Count
        ActiveChart.Legend.LegendEntries(i).LegendKey.Select

        If i =3D "1" Then
           With Selection.Interior
               .ColorIndex =3D 17
           End With
        End If
        If i =3D "2" Then
           With Selection.Interior
               .ColorIndex =3D 18
           End With
        End If
        If i =3D "3" Then
           With Selection.Interior
               .ColorIndex =3D 19
           End With
        End If
        If i =3D "4" Then
            With Selection.Interior
                 .ColorIndex =3D 20
            End With
        End If
        If i =3D "5" Then
           With Selection.Interior
                .ColorIndex =3D 21
           End With
        End If
     Next i
    Next j

End Sub
0
frogman71 (34)
4/29/2008 6:05:31 PM
Reply:

Similar Artilces:

Voice connector on Exchange server 2007.
Is there any functionality available in exchange server 2007 regarding voice connector? If not how can we create it? Thanks in advance. Ashwin Exchange 2007 has the "Universal Messaging" role which is intended for this purpose. Do you have a PBX? -- Ed Crowley MVP - Exchange "Protecting the world from PSTs and brick backups!" "Microsoft Exchange 2007 command shell" <MicrosoftExchange2007commandshell@discussions.microsoft.com> wrote in message news:FAE20A61-AD17-4218-90C2-9356CA90B2A0@microsoft.com... > Is there any functionality available in exch...

Looking for Excel Help
I'm a very novice Excel user and am looking for a little help with creating a formula for a spreadsheet I'm creating for my personal use. I would appreciate some assistance if possible. Thanks in advance. Dan --- Message posted from http://www.ExcelForum.com/ Hi Dan! Post a sample of what you want to do. Your question is just a tad open ended <g> -- Regards Norman Harker MVP (Excel) Sydney, Australia njharker@optusnet.com.au Excel and Word Function Lists (Classifications, Syntax and Arguments) available free to good homes. "DanB4105" <DanB4105.ywtpa@excelfor...

New to excel
Hi All, I'm new to Excel ( and to this forum :) ) and so I hope somebody may b able to help me. I've got 2 questions.... QUESTION 1 I've got a spreadsheet which takes data from one worksheet and uses i to calculate data in a second worksheet using the following code formula: =IF('4th November 2005'!B19="","nothing here dude",IF(B19<'4th Novembe 2005'!B19,"UP",IF(B19='4th November 2005'!B19,"Same",IF(B19>'4t November 2005'!B19,"DOWN")))) The problem is, when I create a new worksheet I have...

Changing Cells and entering data in them
Thanks for the help again. Big thanks to Steve you've got me this far. I went out and bought a book, but it's like reading a foreign language. I was informed today that I can't have message boxes come up. I need to have the code point at the cells and if they are blank turn which ever one is blank red or if both are then both turn red then pause for each cell to be filled in. Cell F14 "Last Name" then automatically go to Cell F16 "First Name" on tab or enter. Basically if Cell F22 or F23 has an X in it, Cells F14 an F16 turn red and cell F14 has the focus...

Excel button problem
Hi All I have a macro that copies a worksheet in the active workbook and puts it into a new workbook - then formats it and deletes any buttons on the worksheet. On the first click on the button the macro works ok. On the second click, it fails because the all assigned macros on all buttons in the active workbook changed from "mba" to "book1!mba". Book 1 doesn't exists (wasn't opened, wasn't saved, doesn't have the macros). I've never experienced this problem before?? Can anyone help to solve this problem? FYI The macro to do this is c...

projecting the notes pages in PPT 2007
I want to project my notes pages to an on stage monitor in while my presentation (sans my notes) are projected behind me...I will run my notes from a second computer... How can I do it? Submitted via EggHeadCafe - Software Developer Portal of Choice C# : Image operations performer http://www.eggheadcafe.com/tutorials/aspnet/bbace980-2554-48d7-9421-73dc29ed3b21/c--image-operations-per.aspx Hi Fred See if Presenter View will do what you want with your set up: http://office.microsoft.com/en-us/powerpoint/HA100673831033.aspx?pid=CH100668261033 Lucy -- Lucy Thomson PowerPoint...

Colored Scroll bars
Hi, We would like to change background color of all scroll bar components in our ..Net application, but change should apply to all controls in our application. I mean not only ScrollBar controls explicitly used, but scroll bars in tree, listview, combo and third-party controls etc. We even have MFC control used through managed c++ wrapper with its own scroll bars. Is there some way to do it (subclassing windows, application-wide hook, etc) ? We can code it Win32 pure if it helps. Alexander Arlievsky. Scroll bars in list controls, tree controls, etc. are not "real" scroll bars, bu...

Excel 97 #9
Please can anyone help??? I have two columns in Excel 97. The first contains a list of statu values eg. pending, or granted or withdrawn. The second contains date eg.01/12/1997, 05/06/2003. I woudl like to know how to get all th granted apps before 31/12/2003. Can anyone help please -- Message posted from http://www.ExcelForum.com theres many ways, but an easiest way would be to do a sort. Highlight the 2 columns, click on data, then sort, then sort by status, then by date. this should group them all together. hope this helps...toe >-----Original Message----- >Please can anyo...

Change position ID in HR
We would like to change the position ID in human resources. Does anyone have a suggestion on this. You would need to do it behind the scenes using a tool like Query Analyzer. -- Charles Allen, MVP "KT" wrote: > We would like to change the position ID in human resources. Does anyone have > a suggestion on this. careful though when you change it on the background as you need to know all the tables that use this position ID or Position Code and change it there too otherwise all the link would be gone and you end up with orphan records that its just the same as creatin...

unable to paste Excel 2003 chart into Outlook 2003
(This was posted on "excel.charting" group.) I have a user who's unable to paste an Excel 2003 chart into Outlook 2003 email message. In Outlook options, the checkbox is selected for "Use Microsoft Office Word 2003 to edit e-mail messages". When I tested this on my own computer running the same version of Office, if the box is check, I have no problem pasting; if this box is cleared, I cannot paste. But on his computer, it doesn't work regardless. Thanks and regards, TL ...

learning Excel #3
Hi, I was considering learning Excel as an additional tool for my data analysis work. Is it better to use data sets that I have previously used with SPSS and apply the same analysis tools as in SPSS? For applying the appropriate tools, I was considering using excel's online help. The second option I have is to use some excel book for data analysis and apply the techniques to data sets provided with the book. Any suggestions????? regards Metal ...

How do I Remove a Split from my Comments in Excel 2003? #2
I have set my current workbook to split/freeze the first column and first 2 rows. Now, when I add a comment to the second row (in any column) my comments are cut off if I should scroll down. I don't ever remember the behavior before. And I don't know what I've done to enable it but it's really annoying. How do turn this off ? ...

Excel corrupts when asking to update vlookups
We are experiencing weird behavior with some Office 2K3 Excel spreadsheets that contain lots of calculations, but no macros. On some pc’s Excel acts normally, on others you get the error. I have a couple of screen shots available. Any help is appreciated. If desired, send your file to my address below. I will only look if: 1. You send a copy of this message on an inserted sheet 2. You give me the newsgroup and the subject line 3. You send a clear explanation of what you want 4. You send before/after examples and expected results. -- Don Gu...

Uninstall of mappoint has caused errors with excel
Hi, I am running Office 2003 on the terminal server (windows 2003) and had a copy of mappoint as well. This is a mapping program. We ininstalled mappoint which has caused an error message with Excel and other office products. The error says "Cd:\documents and settings\administrator.ocrdc1\application data\microsoft\addins c:\Program files\common files\microsoft shared\geography\mpoai9.dll is not a valid add-in." I then click OK and excel opens up and everything is fine. The problem is that we are using other programs as well such as Quickbooks that export to excel and t...

outlook 2007 e-mail
how do you stop e-mails from automatically downloading when you open outlook 2007. i would like to be able to open outlook 2007 and have it wait for me to select 'receive' before downloading e-mails to my system. i know there is a way to do it in outlook 2003 but i do not remember how to do it there and i cannot find how to do it in outlook 2007. -- emerson Uncheck the option to send/receive at a specific interval. --=81 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted w...

how do I add error bars to a 3D chart in excel?
The help states you can only add error bars to data series in 2D area. Is there a way to add them to a 3D chart? Hi, I would not have thought so. Obviously as it is not a built-in option the only way would be a work around perhaps using dummy series. Unfortunately you can create 3d combination charts. Stick with the 2d view. Cheers Andy elahe wrote: > The help states you can only add error bars to data series in 2D area. Is > there a way to add them to a 3D chart? -- Andy Pope, Microsoft MVP - Excel http://www.andypope.info I checked, and error bars are not offered for 3D ch...

Exchange 2007 Content Conversion/Encoiding issue.
Hello I have an Exchange 2007 RTM box running in a Windows 2003 only domain. When we scan a document from our Dell 1815n multifunction and have the output emailed, the document shows up as encoded garble instead of an attached document. A message header from a bad email is below. When we scan a document from the same device and send it to a mailbox that still lives on our last remaining Exchange 2003 server, the output from the scanner is attached as a PDF document normally. Any ideas? Thanks Michael Buckley Header from email recieved to Exchange 2007: (server names and I...

Problem with named range for a large spreadsheet in Excel 2007
Hello, I am trying to generate a large Excel spreadsheet apprx. 10000 rows and 40 columns. I am generating defined name section in the Workbook.xml part of the XLSM package. Here is a sample entry from that section <definedName name="_._44802_._0_._0_._0_._top_line" localSheetId="0" hidden="1">Sheet1!$B$2</definedName> Although the generation goes fine, I can not open the spreadsheet as the Excel throws an error message saying the package is corrupt. But this is not the case if the spreadsheet is small say, 200 rows by 10 columns. ...

Business Portal Development
All: I know how to use Rational XDE, VS and the BP SDK to create new entities in BP, but how does one go about chaning labels? For example, if I wanted to change two labels on a requisition mgt screen: Can I just crack open the ASPX page and change the caption property? Thanks, Dwight -- Hi, To edit the lables you can use front page server extensions 2003. "Dwight Specht" wrote: > All: > > I know how to use Rational XDE, VS and the BP SDK to create new entities in > BP, but how does one go about chaning labels? > > For example, if I wanted to ch...

Excel VBA
When you select the autofilter, the drop down list is created from the unique data in that column. Is there any way to customize this list, so the changes are permanent? For instance, I might have in one(1) column the following 4 row entries: red, blue, green (all are single cell entries) red, blue red blue, green I want my autofilter drop down list to read: red instead of red, blue, green blue red, blue green red blue, green (like normal) If I chose red from the drop down list...

Call & Place Graphic Based on Cell Value?
Is there any way to call & place a graphic image based upon a cell value? Maybe you can look at J.E. McGimpsey's page: http://www.mcgimpsey.com/excel/lookuppics.html documike wrote: > > Is there any way to call & place a graphic image based upon a cell value? -- Dave Peterson ...

How do you change the APR?
How do you change the APR in a Credit Card account? Like if you have to change it from 13.250% to 14.240% Depends on the version but (in M2007) go to the CC Account and click on Change Account Settings. Scroll down to Credit Information and click on Change Credit Details. If you want to change the Minimum payment rate/amount as well, click on the Minimum payment amount and a side window opens. -- Regards Bob Peel, Microsoft MVP - Money For UK tips & fixes see http://support.microsoft.com/default.aspx?scid=fh;EN-GB;mny. I do not respond to any emails that I have not specifically ...

After editing example1.xls and click SAVE, the filename changes to AABBEE.xls
After editing example1.xls and click SAVE, the filename changes to AABBEE.xls. The original file still exist and has been updated but the 'funny' filename also have the same content, and editable. The example1.xls is stored in a server and accessed by many people within the company. Everyone accessing to the file will change the filename unknowingly after saving it. ...

Let me use the Line Color icon on charts
It would speed up a lot of my work if I could use the Line Color icon on Excel charts, the same way I am able to use the Fill Color and Font Color icons. However, when I highlight any chart object, like the Plot Area, Chart Area, or a Series, the Line Color icon is disabled. -- Stuart Bratesman, Jr., MPP Muskie School of Public Service Univ. of Southern Maine Portland, Maine ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If ...

I need to print a word in PDF from excel.
Hi, In my excel Macro, I update several values and then open a word linked with that excel. Finally what I need to do is to print that word to PDF. I already have a PDF Printer, so I just need the code to do it. Can anybody help me? Thanks in advance. Gast=F3n. Habilita la impresora predeterminada como la PDF y ya lo puedes imprimir a al formato deseado Gracias Francisco,=20 Tienes alg=FAn codigo para ello? gracias Repitiendo: Desde el panel de impresoras asigno primero la que me interesa y despues ejecuto mi macro desde el archivo excel asignando la instruccion sig: midefaultes = a...