Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VB for scatter graph help

Hi all,

I've been trying to write some vb to autogenerate a scatter graph where the
data is list in one worksheet. The data comprises dates and values bewtween
1 and 25. The x-axis is the timeline and the y axis is 0-25. There have to
be 4 series where for example 20-25 are coloured red, 15-19 are yellow and
so on. Can anyone point my in the right direction....

Help much appreciated....

Chris

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default VB for scatter graph help

Here is an example that sets the first two colours.

Note that I have created a helper column to split out the values so that
separate series are created.

Sub CreateScatterChart()
Dim myChart As Chart

Range("C1:G1").Value = Array("20", "15", "10", "5", "0")
Range("C2").FormulaR1C1 = "=IF(AND(RC2=20,RC2<=25),RC2,NA())"
Range("D2").FormulaR1C1 = "=IF(AND(RC2=15,RC2<20),RC2,NA())"
Range("E2").FormulaR1C1 = "=IF(AND(RC2=10,RC2<15),RC2,NA())"
Range("F2").FormulaR1C1 = "=IF(AND(RC2=5,RC2<10),RC2,NA())"
Range("G2").FormulaR1C1 = "=IF(AND(RC2=0,RC2<5),RC2,NA())"
Range("C2:G2").AutoFill Destination:=Range("C2:G20")
Set myChart = Charts.Add
With myChart

.ChartType = xlXYScatter
.SetSourceData Source:=Sheets("Sheet2").Range("A1:A20,C1:G20")
.Location Whe=xlLocationAsObject, Name:="Sheet2"
End With

With ActiveChart

With .SeriesCollection(1)
.MarkerBackgroundColorIndex = 3
.MarkerForegroundColorIndex = 3
End With

With .SeriesCollection(2)
.MarkerBackgroundColorIndex = 5
.MarkerForegroundColorIndex = 5
End With
End With
End Sub

--
---
HTH

Bob


(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Chris" wrote in message
...
Hi all,

I've been trying to write some vb to autogenerate a scatter graph where
the data is list in one worksheet. The data comprises dates and values
bewtween 1 and 25. The x-axis is the timeline and the y axis is 0-25.
There have to be 4 series where for example 20-25 are coloured red, 15-19
are yellow and so on. Can anyone point my in the right direction....

Help much appreciated....

Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default VB for scatter graph help

Did you try the macro recorder? That can help get you started.

Then check out:
http://peltiertech.com/Excel/ChartsH...kChartVBA.html

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


"Chris" wrote in message
...
Hi all,

I've been trying to write some vb to autogenerate a scatter graph where
the data is list in one worksheet. The data comprises dates and values
bewtween 1 and 25. The x-axis is the timeline and the y axis is 0-25.
There have to be 4 series where for example 20-25 are coloured red, 15-19
are yellow and so on. Can anyone point my in the right direction....

Help much appreciated....

Chris



Reply
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
excel scatter graph ironwrestler Charts and Charting in Excel 0 February 23rd 11 04:15 AM
Should I use a scatter graph? [email protected] Excel Discussion (Misc queries) 9 September 7th 07 12:57 PM
Should I use a scatter graph? [email protected] Charts and Charting in Excel 1 August 31st 07 01:57 PM
scatter graph pathologist Charts and Charting in Excel 3 May 1st 05 02:39 AM
XY scatter graph gps tech Charts and Charting in Excel 1 February 1st 05 03:29 PM


All times are GMT +1. The time now is 10:23 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"