elogesh
Mechanical
- May 10, 2002
- 187
Hi,
I am begineer in Excel-VBA. Need help to plot graph.
I have two set of data points (A,B) and (D,E) corresponding can also be mentioned as column (1,2) and (4,5)starting from row no.6 to row no.13
A B
0 50
1000 50
2000 50
3000 50
4000 50
5000 50
6000 50
7000 50
8000 50
C D
0 150
1000 150
2000 150
3000 150
4000 150
5000 150
6000 150
7000 150
8000 150
Used the below macro to draw horizontal lines. But I need to draw vertical lines. Kindly let me know, how to draw vertical lines. Also how to change line size and line color
Sub Chassis()
Dim triArray(1 To 8, 1 To 2) As Single
Worksheets("sheet3").Activate
triArray(1, 1) = ActiveSheet.Cells(6, 1).Value
triArray(1, 2) = ActiveSheet.Cells(6, 2).Value
triArray(2, 1) = ActiveSheet.Cells(7, 1).Value
triArray(2, 2) = ActiveSheet.Cells(7, 2).Value
triArray(3, 1) = ActiveSheet.Cells(8, 1).Value
triArray(3, 2) = ActiveSheet.Cells(8, 2).Value
triArray(4, 1) = ActiveSheet.Cells(9, 1).Value
triArray(4, 2) = ActiveSheet.Cells(9, 2).Value
triArray(5, 1) = ActiveSheet.Cells(10, 1).Value
triArray(5, 2) = ActiveSheet.Cells(10, 2).Value
triArray(6, 1) = ActiveSheet.Cells(11, 1).Value
triArray(6, 2) = ActiveSheet.Cells(11, 2).Value
triArray(7, 1) = ActiveSheet.Cells(12, 1).Value
triArray(7, 2) = ActiveSheet.Cells(12, 2).Value
triArray(8, 1) = ActiveSheet.Cells(13, 1).Value
triArray(8, 2) = ActiveSheet.Cells(13, 2).Value
Set myDocument = Worksheets(2)
myDocument.Shapes.AddPolyline triArray
Dim tri1Array(1 To 8, 1 To 2) As Single
tri1Array(1, 1) = ActiveSheet.Cells(6, 4).Value
tri1Array(1, 2) = ActiveSheet.Cells(6, 5).Value
tri1Array(2, 1) = ActiveSheet.Cells(7, 4).Value
tri1Array(2, 2) = ActiveSheet.Cells(7, 5).Value
tri1Array(3, 1) = ActiveSheet.Cells(8, 4).Value
tri1Array(3, 2) = ActiveSheet.Cells(8, 5).Value
tri1Array(4, 1) = ActiveSheet.Cells(9, 4).Value
tri1Array(4, 2) = ActiveSheet.Cells(9, 5).Value
tri1Array(5, 1) = ActiveSheet.Cells(10, 4).Value
tri1Array(5, 2) = ActiveSheet.Cells(10, 5).Value
tri1Array(6, 1) = ActiveSheet.Cells(11, 4).Value
tri1Array(6, 2) = ActiveSheet.Cells(11, 5).Value
tri1Array(7, 1) = ActiveSheet.Cells(12, 4).Value
tri1Array(7, 2) = ActiveSheet.Cells(12, 5).Value
tri1Array(8, 1) = ActiveSheet.Cells(13, 4).Value
tri1Array(8, 2) = ActiveSheet.Cells(13, 5).Value
Set myDocument = Worksheets(2)
myDocument.Shapes.AddPolyline tri1Array
End Sub
I am begineer in Excel-VBA. Need help to plot graph.
I have two set of data points (A,B) and (D,E) corresponding can also be mentioned as column (1,2) and (4,5)starting from row no.6 to row no.13
A B
0 50
1000 50
2000 50
3000 50
4000 50
5000 50
6000 50
7000 50
8000 50
C D
0 150
1000 150
2000 150
3000 150
4000 150
5000 150
6000 150
7000 150
8000 150
Used the below macro to draw horizontal lines. But I need to draw vertical lines. Kindly let me know, how to draw vertical lines. Also how to change line size and line color
Sub Chassis()
Dim triArray(1 To 8, 1 To 2) As Single
Worksheets("sheet3").Activate
triArray(1, 1) = ActiveSheet.Cells(6, 1).Value
triArray(1, 2) = ActiveSheet.Cells(6, 2).Value
triArray(2, 1) = ActiveSheet.Cells(7, 1).Value
triArray(2, 2) = ActiveSheet.Cells(7, 2).Value
triArray(3, 1) = ActiveSheet.Cells(8, 1).Value
triArray(3, 2) = ActiveSheet.Cells(8, 2).Value
triArray(4, 1) = ActiveSheet.Cells(9, 1).Value
triArray(4, 2) = ActiveSheet.Cells(9, 2).Value
triArray(5, 1) = ActiveSheet.Cells(10, 1).Value
triArray(5, 2) = ActiveSheet.Cells(10, 2).Value
triArray(6, 1) = ActiveSheet.Cells(11, 1).Value
triArray(6, 2) = ActiveSheet.Cells(11, 2).Value
triArray(7, 1) = ActiveSheet.Cells(12, 1).Value
triArray(7, 2) = ActiveSheet.Cells(12, 2).Value
triArray(8, 1) = ActiveSheet.Cells(13, 1).Value
triArray(8, 2) = ActiveSheet.Cells(13, 2).Value
Set myDocument = Worksheets(2)
myDocument.Shapes.AddPolyline triArray
Dim tri1Array(1 To 8, 1 To 2) As Single
tri1Array(1, 1) = ActiveSheet.Cells(6, 4).Value
tri1Array(1, 2) = ActiveSheet.Cells(6, 5).Value
tri1Array(2, 1) = ActiveSheet.Cells(7, 4).Value
tri1Array(2, 2) = ActiveSheet.Cells(7, 5).Value
tri1Array(3, 1) = ActiveSheet.Cells(8, 4).Value
tri1Array(3, 2) = ActiveSheet.Cells(8, 5).Value
tri1Array(4, 1) = ActiveSheet.Cells(9, 4).Value
tri1Array(4, 2) = ActiveSheet.Cells(9, 5).Value
tri1Array(5, 1) = ActiveSheet.Cells(10, 4).Value
tri1Array(5, 2) = ActiveSheet.Cells(10, 5).Value
tri1Array(6, 1) = ActiveSheet.Cells(11, 4).Value
tri1Array(6, 2) = ActiveSheet.Cells(11, 5).Value
tri1Array(7, 1) = ActiveSheet.Cells(12, 4).Value
tri1Array(7, 2) = ActiveSheet.Cells(12, 5).Value
tri1Array(8, 1) = ActiveSheet.Cells(13, 4).Value
tri1Array(8, 2) = ActiveSheet.Cells(13, 5).Value
Set myDocument = Worksheets(2)
myDocument.Shapes.AddPolyline tri1Array
End Sub