Problem in plotting XYscatter chart in excel VBA

sharathdude
05-19-2010, 06:32 AM
I have written code in Excel VBA to create XYscatter chart inside chartspace.The code contains a number of data series to be plotted inside the chartspace. The values for the data series are tobe read from the sheet1 of the workbook. The code is as follows.

Private Sub CommandButton1_Click()
ChartSpace1.Height = 282 * 1.75
ChartSpace1.Width = 318 * 1.75
Dim chConstants

'Dim xValues As Variant, yValues As Variant
Dim Spreadsheet1 As OWC10.Spreadsheet

' Set the data source of the chart to the Spreadsheet control.
Set Spreadsheet1 = CreateObject("OWC10.Spreadsheet")
Spreadsheet1.Range("A1", "Z1000") = Sheet1.Range("A1", "Z1000").Value

'Set c = ChartSpace1.Constants
Set ChartSpace1.DataSource = Spreadsheet1
Set chConstants = ChartSpace1.Constants

'Create a Xy scatter chart chart.
ChartSpace1.Charts(0).Type = chChartTypeScatterLine

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a2"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B2:B3"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C2:C3"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a3"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B16:B17"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C16:C17"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a4"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B18:B19"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C18:C19"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a5"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B20:B21"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C20:C21"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a6"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B22:B23"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C22:C23"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a7"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B24:B25"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C24:C25"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a8"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B26:B27"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C26:C27"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a9"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B29:B30"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C29:C30"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a10"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B32:B33"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C32:C33"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a11"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B35:B36"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C35:C36"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a12"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B38:B39"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C38:C39"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a13"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B41:B42"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C41:C42"

' Bind the series name to cell B1 in the first sheet of Spreadsheet1.
'ChartSpace1.Charts(0).SeriesCollection.Add
ChartSpace1.Charts(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a14"

' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B44:B45"
' Bind the values of the data series to cells B2:B28 in the first sheet of Spreadsheet1.
ChartSpace1.Charts(0).SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C44:C45"

End Sub

Th problem with this code is when I click the command button, it plots only the last data series in the chartspace and not all the data series. I want all the data series to be plotted inside the chartspace when I click the PLOT button in the user form. Can some one correct my code. I am also attaching the excel file contaning the VB code for ur reference

Regards,
Sharath

JSTKwan
05-19-2010, 08:39 AM
You are always using one series, therefore, you plot a line, then replot with next set of data......
Replace your Userform1 Plot button code with below:

Private Sub CommandButton1_Click()
ChartSpace1.Height = 282 * 1.75
ChartSpace1.Width = 318 * 1.75
Dim chConstants

'Dim xValues As Variant, yValues As Variant
Dim Spreadsheet1 As OWC10.Spreadsheet

' Set the data source of the chart to the Spreadsheet control.
Set Spreadsheet1 = CreateObject("OWC10.Spreadsheet")
Spreadsheet1.Range("A1", "Z1000") = Sheet1.Range("A1", "Z1000").Value

'Set c = ChartSpace1.Constants
Set ChartSpace1.DataSource = Spreadsheet1
Set chConstants = ChartSpace1.Constants

'Create a Xy scatter chart chart.
ChartSpace1.Charts(0).Type = chChartTypeScatterLine

With ChartSpace1.Charts(0)
.SeriesCollection.Add
.SeriesCollection(0).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a2"
.SeriesCollection(0).SetData chConstants.chDimXValues, chConstants.chDataBound, "B2:B3"
.SeriesCollection(0).SetData chConstants.chDimYValues, chConstants.chDataBound, "C2:C3"

.SeriesCollection.Add
.SeriesCollection(1).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a3"
.SeriesCollection(1).SetData chConstants.chDimXValues, chConstants.chDataBound, "B16:B17"
.SeriesCollection(1).SetData chConstants.chDimYValues, chConstants.chDataBound, "C16:C17"

.SeriesCollection.Add
.SeriesCollection(2).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a4"
.SeriesCollection(2).SetData chConstants.chDimXValues, chConstants.chDataBound, "B18:B19"
.SeriesCollection(2).SetData chConstants.chDimYValues, chConstants.chDataBound, "C18:C19"

.SeriesCollection.Add
.SeriesCollection(3).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a5"
.SeriesCollection(3).SetData chConstants.chDimXValues, chConstants.chDataBound, "B20:B21"
.SeriesCollection(3).SetData chConstants.chDimYValues, chConstants.chDataBound, "C20:C21"

.SeriesCollection.Add
.SeriesCollection(4).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a6"
.SeriesCollection(4).SetData chConstants.chDimXValues, chConstants.chDataBound, "B22:B23"
.SeriesCollection(4).SetData chConstants.chDimYValues, chConstants.chDataBound, "C22:C23"

.SeriesCollection.Add
.SeriesCollection(5).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a7"
.SeriesCollection(5).SetData chConstants.chDimXValues, chConstants.chDataBound, "B24:B25"
.SeriesCollection(5).SetData chConstants.chDimYValues, chConstants.chDataBound, "C24:C25"

.SeriesCollection.Add
.SeriesCollection(6).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a8"
.SeriesCollection(6).SetData chConstants.chDimXValues, chConstants.chDataBound, "B26:B27"
.SeriesCollection(6).SetData chConstants.chDimYValues, chConstants.chDataBound, "C26:C27"

.SeriesCollection.Add
.SeriesCollection(7).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a9"
.SeriesCollection(7).SetData chConstants.chDimXValues, chConstants.chDataBound, "B29:B30"
.SeriesCollection(7).SetData chConstants.chDimYValues, chConstants.chDataBound, "C29:C30"

.SeriesCollection.Add
.SeriesCollection(8).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a10"
.SeriesCollection(8).SetData chConstants.chDimXValues, chConstants.chDataBound, "B32:B33"
.SeriesCollection(8).SetData chConstants.chDimYValues, chConstants.chDataBound, "C32:C33"

.SeriesCollection.Add
.SeriesCollection(9).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a11"
.SeriesCollection(9).SetData chConstants.chDimXValues, chConstants.chDataBound, "B35:B36"
.SeriesCollection(9).SetData chConstants.chDimYValues, chConstants.chDataBound, "C35:C36"

.SeriesCollection.Add
.SeriesCollection(10).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a12"
.SeriesCollection(10).SetData chConstants.chDimXValues, chConstants.chDataBound, "B38:B39"
.SeriesCollection(10).SetData chConstants.chDimYValues, chConstants.chDataBound, "C38:C39"

.SeriesCollection.Add
.SeriesCollection(11).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a13"
.SeriesCollection(11).SetData chConstants.chDimXValues, chConstants.chDataBound, "B41:B42"
.SeriesCollection(11).SetData chConstants.chDimYValues, chConstants.chDataBound, "C41:C42"

.SeriesCollection.Add
.SeriesCollection(12).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a14"
.SeriesCollection(12).SetData chConstants.chDimXValues, chConstants.chDataBound, "B44:B45"
.SeriesCollection(12).SetData chConstants.chDimYValues, chConstants.chDataBound, "C44:C45"

.SeriesCollection.Add
.SeriesCollection(13).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a15"
.SeriesCollection(13).SetData chConstants.chDimXValues, chConstants.chDataBound, "B47:B48"
.SeriesCollection(13).SetData chConstants.chDimYValues, chConstants.chDataBound, "C47:C48"

.SeriesCollection.Add
.SeriesCollection(14).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "a16"
.SeriesCollection(14).SetData chConstants.chDimXValues, chConstants.chDataBound, "B50:B51"
.SeriesCollection(14).SetData chConstants.chDimYValues, chConstants.chDataBound, "C50:C51"

End With
'ChartSpace1.Charts(0).SeriesCollection.NewSeries
'ChartSpace1.Charts(0).SeriesCollection.NewSeries
'ChartSpace1.Charts(0).SeriesCollection.NewSeries
' Set the properties of the first data series.
'ChartSpace1.DataSource = Sheet1.Object
'ChartSpace1.Charts(0).SetData chDimXValues, 0, "b2:b3"
'ChartSpace1.Charts(0).SetData chDimYValues, 0, "c2:c3"
'ChartSpace1.Charts(0).SetData chDimXValues, 0, "b2:b4"
'ChartSpace1.Charts(0).SetData chDimYValues, 0, "c2:c4"
'ChartSpace1.Charts(0).SetData chDimXValues, 0, "b3:b4"
'ChartSpace1.Charts(0).SetData chDimYValues, 0, "c3:c4"
'ChartSpace1.Charts(0).SeriesCollection (1), 0, "b2:b3"
'ChartSpace1.Charts(0).SeriesCollection (1), 0, "c2:c3"
'ChartSpace1.Charts(0).SeriesCollection(2).xValues = "=(Sheet1!R2C2,Sheet1!R4C2)"
'ChartSpace1.Charts(0).SeriesCollection(2).Values = "=(Sheet1!R2C3,Sheet1!R4C3)"
'ChartSpace1.Charts(0).SeriesCollection(3).XValues = "=(Sheet1!R4C2,Sheet1!R3C2)"
'ChartSpace1.Charts(0).SeriesCollection(3).Values = "=(Sheet1!R4C3,Sheet1!R3C3)"


End Sub

sharathdude
05-20-2010, 12:33 AM
Thanx for the correction. Code is working properly now but there is some problem. I removed the code from the command button and put it inside a scrollbar, when i try to run the program I get the following error.

Run time error '-2147024809 (80070057)':
A Chart may only have up to 256 series

please let me know what is the problem

Also If i want to read the values for data series from textboxes within the userform and not from the cells in the excel sheet, how should I modify my code to achieve that. Please suggest.

Regards,
Sharath

JSTKwan
05-20-2010, 05:43 PM
Best to post your workbook.

sharathdude
05-20-2010, 10:58 PM
Hello,

I have attached my workbook.

Workbook contains a user form with 3 scrollbars and a chartspace inside it. The values for the scrollbars and the chartspace are refered from the excel sheet1. When I run the program by scrolling any one of the three scrollbars, the program runs normally for some time and after precisely the 13th click on the scrollbar I get the error message saying

Run time error '-2147024809 (80070057)':
A Chart may only have up to 256 series

please let me know what is the problem

Also If i want to read the values for data series from textboxes within the userform and not from the cells in the excel sheet, how should I modify my code to achieve that. Please suggest.

Regards,
Sharath

JSTKwan
06-02-2010, 08:51 AM
Try attached workbook

JSTKwan
06-02-2010, 09:54 AM
This is actually better, I shortened your code and if I made all the translations properly...
I would use this instead of the workbook that I posted back with the previous post, just overwrite your code in Userform1 with below
As to reading your graph, I've changed the labels to the reading of the scroll bar, I think that is what you meant, not sure.

Dim ext_boom, ext_arm, ext_bucket As Integer
Dim GraphSet As Boolean
Dim Spreadsheet1 As OWC10.Spreadsheet
Dim chConstants
Sub UpdateGraph()
Set chConstants = ChartSpace1.Constants
StartRow = 2
StartCell = 7
With ChartSpace1.Charts(0)
For i = 0 To 20
If Not GraphSet Then .SeriesCollection.Add
.SeriesCollection(i).SetData chConstants.chDimSeriesNames, chConstants.chDataBound, "A" & StartRow
.SeriesCollection(i).SetData chConstants.chDimXValues, chConstants.chDataBound, "M" & StartCell & ":M" & StartCell + 1
.SeriesCollection(i).SetData chConstants.chDimYValues, chConstants.chDataBound, "N" & StartCell & ":N" & StartCell + 1
Select Case i
Case 0, 8, 9
.SeriesCollection(i).Line.Color = "black"

Case 1, 3, 15, 18
.SeriesCollection(i).Line.Color = "red"

Case 4, 6, 11, 16, 17, 19
.SeriesCollection(i).Line.Color = "brown"

Case 2, 5, 7
.SeriesCollection(i).Line.Color = "green"

Case 10, 12, 13, 14, 20
.SeriesCollection(i).Line.Color = "blue"

Case Else
MsgBox "not set"
End Select

.SeriesCollection(i).Line.Weight = xlThin
.SeriesCollection(i).Line.Miter = xlContinuous
StartRow = StartRow + 1
StartCell = StartCell + 2
Next i
End With
' ChartSpace1.ExportPicture "chart.jpg", Width:=1112, Height:=988
GraphSet = True
End Sub
Private Sub ScrollBar1_Change()
Dim x1, CCD_BOOM, OCD_BOOM As Integer
Dim x2, CCD_ARM, OCD_ARM As Integer

CCD_BOOM = [c44].Value
OCD_BOOM = [c45].Value
x1 = ScrollBar1.Value
ext_boom = CCD_BOOM + (OCD_BOOM - CCD_BOOM) * x1 / 100
'TextBox32.Value = Round(ext_boom)
[c53].Value = Round(ext_boom)
Label28.Caption = Round(ext_boom)

CCD_ARM = [c47].Value
OCD_ARM = [c48].Value
x2 = ScrollBar2.Value
ext_arm = CCD_ARM + (OCD_ARM - CCD_ARM) * x2 / 100
'TextBox60.Value = Round(ext_arm)
[c54].Value = Round(ext_arm)
Label29.Caption = Round(ext_arm)
Dim x3, CCD_BUCKET, OCD_BUCKET As Integer
CCD_BUCKET = [c50].Value
OCD_BUCKET = [c51].Value
x3 = ScrollBar3.Value
ext_bucket = CCD_BUCKET + (OCD_BUCKET - CCD_BUCKET) * x3 / 100
'TextBox61.Value = Round(ext_bucket)
[c55].Value = Round(ext_bucket)
Label30.Caption = Round(ext_bucket)

'Set the data source of the chart to the Spreadsheet control.
Spreadsheet1.Range("A1", "Z1000") = Sheet1.Range("A1", "Z1000").Value
Set ChartSpace1.DataSource = Spreadsheet1

'Create a Xy scatter chart chart.
UpdateGraph
End Sub
Private Sub ScrollBar2_Change()
Dim x1, CCD_BOOM, OCD_BOOM As Integer
Dim x2, CCD_ARM, OCD_ARM As Integer

CCD_BOOM = [c44].Value
OCD_BOOM = [c45].Value
x1 = ScrollBar1.Value
ext_boom = CCD_BOOM + (OCD_BOOM - CCD_BOOM) * x1 / 100
'TextBox32.Value = Round(ext_boom)
[c53].Value = Round(ext_boom)
Label28.Caption = Round(ext_boom)

CCD_ARM = [c47].Value
OCD_ARM = [c48].Value
x2 = ScrollBar2.Value
ext_arm = CCD_ARM + (OCD_ARM - CCD_ARM) * x2 / 100
'TextBox60.Value = Round(ext_arm)
[c54].Value = Round(ext_arm)
Label29.Caption = Round(ext_arm)
Dim x3, CCD_BUCKET, OCD_BUCKET As Integer
CCD_BUCKET = [c50].Value
OCD_BUCKET = [c51].Value
x3 = ScrollBar3.Value
ext_bucket = CCD_BUCKET + (OCD_BUCKET - CCD_BUCKET) * x3 / 100
'TextBox61.Value = Round(ext_bucket)
[c55].Value = Round(ext_bucket)
Label30.Caption = Round(ext_bucket)

'Set the data source of the chart to the Spreadsheet control.
Spreadsheet1.Range("A1", "Z1000") = Sheet1.Range("A1", "Z1000").Value
Set ChartSpace1.DataSource = Spreadsheet1

'Create a Xy scatter chart chart.
UpdateGraph
End Sub
Private Sub ScrollBar3_Change()
Dim x1, CCD_BOOM, OCD_BOOM As Integer
Dim x2, CCD_ARM, OCD_ARM As Integer

CCD_BOOM = [c44].Value
OCD_BOOM = [c45].Value
x1 = ScrollBar1.Value
ext_boom = CCD_BOOM + (OCD_BOOM - CCD_BOOM) * x1 / 100
'TextBox32.Value = Round(ext_boom)
[c53].Value = Round(ext_boom)
Label28.Caption = Round(ext_boom)

CCD_ARM = [c47].Value
OCD_ARM = [c48].Value
x2 = ScrollBar2.Value
ext_arm = CCD_ARM + (OCD_ARM - CCD_ARM) * x2 / 100
'TextBox60.Value = Round(ext_arm)
[c54].Value = Round(ext_arm)
Label29.Caption = Round(ext_arm)
Dim x3, CCD_BUCKET, OCD_BUCKET As Integer
CCD_BUCKET = [c50].Value
OCD_BUCKET = [c51].Value
x3 = ScrollBar3.Value
ext_bucket = CCD_BUCKET + (OCD_BUCKET - CCD_BUCKET) * x3 / 100
'TextBox61.Value = Round(ext_bucket)
[c55].Value = Round(ext_bucket)
Label30.Caption = Round(ext_bucket)

'Set the data source of the chart to the Spreadsheet control.
Spreadsheet1.Range("A1", "Z1000") = Sheet1.Range("A1", "Z1000").Value
Set ChartSpace1.DataSource = Spreadsheet1

'Create a Xy scatter chart chart.
UpdateGraph
End Sub
Private Sub TextBox1_Change()
x1 = Val(TextBox1.Text)
End Sub
Private Sub UserForm_Initialize()
GraphSet = False
ChartSpace1.Height = 494
ChartSpace1.Width = 556
ChartSpace1.Charts(0).Type = chChartTypeScatterLine
Set Spreadsheet1 = CreateObject("OWC10.Spreadsheet")
Set ChartSpace1.DataSource = Spreadsheet1
Set chConstants = ChartSpace1.Constants
End Sub
Private Sub UserForm_Terminate()
Set Spreadsheet1 = Nothing
End Sub

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum