Re: Creating Chart And Pasting Into Word
I'm a little confused on the above code. Would it be easier to do this: forget about arrays, search for my values in my (software-generated) excel in sheet1, fill one row after another in sheet 2 of all the values I find, then make a chart from sheet 2 (since now i know the specific range) ? Sorry I'm not very good with this...
Code
Private Function rungraph850(graph850 as variant) as variant
If (graph850 = "") Or (graph850 = "False.xls") Then
Exit Function
End If
Workbooks.Open (graph850)
'Dim vntArrayX(124) As Integer
'Dim vntArrayY(124) As Double
Dim H As Integer
Dim objChart As Chart
Charts.Add
For H = 1 To 392
If (Worksheets("Sheet1").Range("A1").Cells(H, "A") < 0) Then 'object not suport property/method error
MsgBox ("it works")
Worksheets("Sheet2").Range("A1").Cells((H - 23) / 3, "A") = (H - 23) / 3 + 128
Worksheets("Sheet2").Range("A1").Cells((H - 23) / 3, "B") = Sheet1.Range("A1").Cells(H, "D").Value
'vntArrayX((H - 23) / 3) = ((H - 23) / 3 + 128)
'vntArrayY((H - 23) / 3) = ActiveSheet.Range("A1").Cells(H, "D").Value
End If
Next H
Set objChart = ActiveSheet.Sheet(2).ChartObjects.Add(1, 1, 600, 300).chart
With objChart
.ChartType = xlLine
With .SeriesCollection.NewSeries
.XValues = "=Sheet2!R1C1:R123C1"
.Values = "=Sheet2!R1C2:R123C2"
End With
'End With
'MsgBox (array850(169))
'ActiveWorkbook.Close
'Set objChart = Nothing
End Function
Display More