Macro commands to assign colors to each line in an Excel chart.

Is there a macro command that will assign a user specifide color to each 
individual line of a scatter graph?
0
JohnnyC (2)
7/2/2009 6:58:01 PM
excel.charting 18370 articles. 0 followers. Follow

3 Replies
651 Views

Similar Articles

[PageSpeed] 40

Hi,

First, scatter charts do not usually display as lines, so when you say line 
what do you mean?  You chosen as style with connecting lines? or you are 
refering to drop lines, or error bar lines, or...?

You can tell Excel to vary the color by point but if you want to assign 
specific colors to specific points you will need to write a macro.  What 
version of Excel are you using?


-- 
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"JohnnyC" wrote:

> Is there a macro command that will assign a user specifide color to each 
> individual line of a scatter graph?
0
7/2/2009 10:13:01 PM
Hi,

Here is a macro approach:  suppose your data is in the range A2:B12, then 
format each of the cell in C2:C12 to the desired color you want to apply to 
the line.  Then select the chart and run the following macro:

Sub ColorLines()
    Dim cell As Range
    Dim I As Integer
    I = 1
    For Each cell In Sheets("Sheet3").Range("C2:C12")
        ActiveChart.SeriesCollection(1).Points(I).Select
        Selection.Border.ColorIndex = cell.Interior.ColorIndex
        I = I + 1
    Next cell
End Sub

Remember the first color is ignored because there is no line associated with 
the first data point.

-- 
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"JohnnyC" wrote:

> Is there a macro command that will assign a user specifide color to each 
> individual line of a scatter graph?
0
7/2/2009 10:28:01 PM
I have just started using Excel 2007 and have a macro that is not working 
from the 2003 version.  Here is the old code for adjusting the line color for 
the third line in the XYScatterLines graph :

    ActiveChart.Legend.LegendEntries(3).LegendKey.Select
    With Selection.Border
        .ColorIndex = 3
        .Weight = xlThin
        .LineStyle = xlContinuous
    End With
    With Selection
        .MarkerBackgroundColorIndex = 3
        .MarkerForegroundColorIndex = 3
        .MarkerStyle = xlTriangle
        .Smooth = False
        .MarkerSize = 5
        .Shadow = False
    End With

The old version would make the triangles and line connecting the triangles 
red, but the new version makes the triangles red, the line connecting the 
triangles is not.  Any help would be greatly appreciated.

JohnnyC
"Shane Devenshire" wrote:

> Hi,
> 
> Here is a macro approach:  suppose your data is in the range A2:B12, then 
> format each of the cell in C2:C12 to the desired color you want to apply to 
> the line.  Then select the chart and run the following macro:
> 
> Sub ColorLines()
>     Dim cell As Range
>     Dim I As Integer
>     I = 1
>     For Each cell In Sheets("Sheet3").Range("C2:C12")
>         ActiveChart.SeriesCollection(1).Points(I).Select
>         Selection.Border.ColorIndex = cell.Interior.ColorIndex
>         I = I + 1
>     Next cell
> End Sub
> 
> Remember the first color is ignored because there is no line associated with 
> the first data point.
> 
> -- 
> If this helps, please click the Yes button.
> 
> Cheers,
> Shane Devenshire
> 
> 
> "JohnnyC" wrote:
> 
> > Is there a macro command that will assign a user specifide color to each 
> > individual line of a scatter graph?
0
JohnnyC (2)
7/6/2009 10:46:01 AM
Reply:

Similar Artilces:

Chart to represent sale number by individual contrubtion vs total
I need help on how to create a chart to represent sales number by individual contributor vs total. E.g. Alvin = $50 Mary = $150 John = $80 Kate = $120 Total = $400 The chart should show a graphical representation of $400 as the total, and it shows how each person contribute to the chart. Hi, One way would be to plot the data, not including the total as a stacked column. Alternately, you could plot the data without the total as a column chart and then plot the total as a line on the same chart. Just make a second series with each item the total. -- If this helps, please click th...

Macro warning with no macros
I have a workbook that when I try to open it I get the warning tellin me it contains macros and asking whether I want to Enable or Disabl them. I put no macros, no VB scripts, nothing at all in the workboo other than standard Excel formulas and some charts. I developed it i Excel 2002, SP-2, but have moved it back and forth between tw computers, the other which has Excel 97. Regardless of whether Enable or Disable or change the security settings so as not to get th warning, once the workbook is open even if I go t Tools-Macro-Macros... it lists no macros. How can I find out what's cau...

saving the history of recently used excel documentsto another comp
Reimaging a computer and wanting to know if I can export the excel history to the new image. Most files are on the network and not sure where they are, don't want to remap them all If you're referring to the files listed at the bottom of the File menu you'd have to run the Regedit program and go to this key: HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Excel\Recent Files replacing the "11.0" with your Excel version if different. Then you would have to right click on the Recent Files folder and Export it. After the reimage you would double-click the resultin...

when inserting a chart excel is saying i cannot add any new fonts
When I attempt to insert a chart i am getting a message which says,"no new fonts may be added to this workbook". I am adding it to a billing process and I did the first 100 or so before it began this doing this, I am not adding any new fonts but I am getting this message, any suggestions on what is the cause so I can overcome it? I've described the problem and fix here: Error: "No more new fonts may be applied in this workbook" http://peltiertech.com/Excel/Charts/FixFonts.html - Jon ------- Jon Peltier Peltier Technical Services, Inc. http://peltier...

Macro
Can anybody tell me how to kick off a macro automatically as file is opened? Regards ...

Shade under a line
I have scatterplots with date/time along the X axis, and data on the Y axis. I'd like to add shading from sunrise to sunset. I can create a line on the scatterplot that is 0 during the day and a value greater than the max Y value at night, but would like to be able to shade under this line to more easily visualize when it's dark. I also tried creating a bar graph in the background on a second X axis, thinking I could have small categories with date and light/dark data, but the time axis cannot do increments smaller than days, so that hasn't worked. Any suggestions? I ha...

Macro
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: intel Hi, I'm thinking of buying Mac: Office 2008, but before I do I want to check that I will be able to download Scritpsmart collection of templates without any glitches: <http://www.bbc.co.uk/writersroom/scriptsmart/faq.shtml> Does anyone know if I can do this? Regards, SP. In article <ee98ff5.-1@webcrossing.caR9absDaxw>, StregaItalia@officeformac.com wrote: > Version: 2008 > Operating System: Mac OS X 10.4 (Tiger) > Processor: intel > > Hi, > > I'm thinking of buying Mac: Of...

Run macro automatically.
How do I make a macro run automatically when a worksheet it is attached to is loaded? right click on the sheet tab>view code>left window worksheet>right window activate -- Don Guillett SalesAid Software donaldb@281.com "Excel macro" <Excel macro@discussions.microsoft.com> wrote in message news:DD7AF1E3-9263-4523-AC49-A43ABA1AB9D0@microsoft.com... > How do I make a macro run automatically when a worksheet it is attached to is > loaded? I am unable to find "activate " when I right click on worksheet. ( i assume that you are referring to the windo...

Excel separator pages
When printing multiple copies of a spreadsheet if it is set to collate I get multiple separator pages 1 for each copy, if I turn off the collate option, I only get 1 separator page. Can this be adjusted in any way so I don't get multiple separator pages even when I use the default collate option?? ...

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 ...

Help with macro/and or formula?
Perhaps this is a silly question, but i just can't figure out how t format this worksheet. The problem is that a lot of the cells hav numbers in them with negative signs in the back instead of in the fron (ie. 23-) and i was wondering if anyone knew of a macro/formula i coul use to quickly fix this problem for all the cells. I would b extremely grateful. Thanks -- brefed1 ----------------------------------------------------------------------- brefed15's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=3557 View this thread: http://www.excelforum.com/showthre...

Attached Toolbars Macros
Excel 2003 I have a custom tool bar, this tool bar has several items, each item is pointing to a VBA code. This tool bar is attached to the worksheet. I've copied this spreadsheet to several computers. After I copied the spreadsheet I decided to rename the spreadsheet, after I renamed the spreadsheet the Toolbar Item's macros were still pointing to the old name, I reasigned each tool bar item to the current spreadsheet, saved the spreadsheet and everything was working on my computer, but when I re-copied the new spreadsheet to other computers and I clicked on the Toolbar Item...

pivot chart add a ligne not in the pivot table
hello, I've a pivot table and the related graph and I would like to add 2 ligne who represents the minimun and maximum value before alarm. I would like to knwo how to create 2 ligne in a chart by vba Thanks You can create a normal chart, based on the pivot table, and include the additional lines in that. On Jon Peltier's site, there are instructions for creating a normal chart from pivot data: http://www.peltiertech.com/Excel/Pivots/pivotcharts.htm And for adding lines to a chart: http://www.peltiertech.com/Excel/Charts/ComboCharts.html#AddLine To create the code, you ...

Protected sheets and running macros
i have a sheet with a macro ran by a normal button at the top. Howeve when i protect the worksheet where ever i click on the sheet the macr executes. Can any one offer any advice on how to stop this? Thanks Robert -- Message posted from http://www.ExcelForum.com hi, i am not able to reproduce the problem, hence i may not be able t provide a panacea for that issue. here is what i suggest. i have a sheet that has a macro that is run when a control toolbo button (that is, not a form button) is clicked. this sheet is protected based on the user logged in. what i have don is to protect t...

VBA Command to Look at cell in an If statement
I need to create a macro in VBA that will look at a specific cell (which contains the result of a lookup formula) in an If statement. Basically it would look at a certian cell, and If that cell had the word "YES", then it would execute a seprate macro. If not, just continue on it merry way. I have tried the following and several variations: Sheets("Print Area").Select Range("BO8:BO8").Select If BO8 = YES Then Call PrintBatch What the program has to do is look at the last entry made in a specific column (hence the use of the Lookup formula in the cell) and...

Macro Freezes Reading Pane
I have a macro that Sends/Receives Tasks from Project Server into Outlook Tasks. Everything is working fine, except one weird thing that happens. I have the Timer set on the macro and it starts as soon as Outlook starts. The macro gets the tasks from ProjectServer every hour. As soon as the macro starts running the Reading pane freezes in the Inbox. If i stop the macro then Reading pane is back to normal. Can anyone please tell me if there is something I can do in VBA to fix this annoying issue. Thanks a lot ...

Macro to remove rows?
Hi, I receive thousands of rows of data from an extract that comes from a database. The data extract automatically generates page headers that need to be removed, and I would love to automate this process. The headers do have a pattern to them, but I'm not clever enough to figure out a good way to use that to write a macro. The first row of the header starts with hyphens ------------------------------- Then there's a variable number of rows of header data to delete followed by another row of hyphens ------------------------------- Then 2 additional rows that must be deleted. The nu...

Saving in 2003 Excel
I am currently taking Excel 2002 in college. The software I have loaded is 2003 but my Professor is running 2002. Can someone tell me how ot save in 2003 so the Professor can read in 2002? Hi Terry! Just save normally. You version challenged Professor will be able to open it. -- 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. Same file format, no problems.. -- Regards, Peo Sjoblom "Terry" <our.email@fuse.net> wrote in message news:384d...

Archive command does not remove anything
We have not tried to archive since installing exchange 2003 Trying to get users in a good habit I put a warning message to tell people to start archiving to a .pst file on there local machine, It does not work for any one, this feature was fine when we used to use microsoft mail with everyones mail on their own .pst files. We click file then archive and the icon shows in the lower right corner that it is doing something but nothing leaves the inbox and no copies of messages appear in the archive folders. There are no error messages. It looks like the process has worked but nothing hap...

Calling on a macro within a macro!
Hey All!! Quick Question - How do you call up a macro within a current macro? I have one big macro and I need it to jump to several other macros when it runs! Does it matter where the other macros are stored or is it better to have them all in one module? Help appreciated Thnx! Hi Mellowe, '=============>> Public Sub Main() 'Your code Call One 'your code End Sub '<<============= '=============>> Public Sub One() MsgBox "Hi from One" End Sub '<<============= > Does it matter where the other macros are stored or ...

Trend Line constants as Excel Cell Values
I want to put the constants of a 2 degree polynomial trend line into Excel Cells. Are there formula's to do this? Equation is Y = Ax(2) + Bx + C. I want the value of A,B and C in seperate cells. Can anyone suggest how this can be done? Thanks -- Ken Hi Ken, Supposing your x-range is in A2:A10, and y-range in B2:B10, select a 3-column x 1-row area and enter the following formula and confirm with CTRL-SHIFT-ENTER. =LINEST(B2:B10,A2:A10^{0,1,2},0,) Regards, B. R. Ramachandran "Ken" wrote: > I want to put the constants of a 2 degree polynomial trend line into Excel &g...

Retain Field Format From Excel
I have an excel file that I'm importing to Access. This field consists of "time"...hours, minutes, seconds. The format in excel is set to "Custom" - [h]:mm:ss. The data elements look like 150:27:50, 2:30:25, etc... The time stays the same for some records but others change. For example...150:27:50 becomes 6:27:50 AM when imported. If someone can help me figure a way to retain the format for all records I would greatly appreciate it. Thank You, Lisa W. 150 divided by 24 = 6.25 or 6 and 1/4 days which is displayed a 6 AM. You need to use a ...

shortcut keys to macros
Hi, Is it at all possible to assign shortcut keys to macros in Outlook? Thx, Hans ...

help Unable to record Macro !!!!!!!
I want to record a macro in excel.But as soon as I click record Macro it says "unable to record" macro. Got no help in excel help.I do this same thing in word and it's working. Please help It's urgent for me !!!1 Have a look here http://groups.google.com/groups?as_epq=unable%20to%20record&as_ugroup=microsoft.public.excel.* -- Don Guillett SalesAid Software donaldb@281.com "ash" <anonymous@discussions.microsoft.com> wrote in message news:3e0b01c42ae5$45333e00$a401280a@phx.gbl... > I want to record a macro in excel.But as soon as I click > record...

Macro that password protects a sheet
I am attempting to create a macro that can open a protected sheet, change something, and then protect it again. I continue to have an issue with the macro not entering the password. Is this possible to do/fix? Thanks, Ryan ..open password="mypassword" -- Don Guillett SalesAid Software donaldb@281.com "Ryan" <Ryan@discussions.microsoft.com> wrote in message news:D4780ED8-CA1D-4284-97BC-3576160D998E@microsoft.com... > I am attempting to create a macro that can open a protected sheet, change > something, and then protect it again. I continue to have an iss...