# Chart with lines connecting 2 different X Y points

#### JugglerJAF

##### Active Member
I'm trying to figure out how to re-create in Excel those curves that everyone drew as a kid by connecting points on an X and Y axis. One of these:

For example, I want to plot:
• point 0,5 and connect it with a line to the point 1,0
• point 0,4 and connect it with a line to the point 2,0
• point 0,3 and connect it with a line to the point 3,0
• point 0,2 and connect it with a line to the point 4,0
• point 0,1 and connect it with a line to the point 5,0
I've tried a few layouts and approaches, line charts and XY Scatter charts, but I can't get it to plot the points and connecting lines as I want. I'm sure there's a simple way to do this, but I can't figure it out. Help!!

### Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},\$Z\$1:\$Z\$99,\$Y\$1:\$Y\$99),2,False) to lookup Y values to left of Z values.

#### goesr

##### Well-known Member

Hello - JugglerJAF - You might try something like the code below. Hope this helps.

VBA Code:
``````Sub PatternWithLines()
Set myDocument = Worksheets(1)
i = 10
While i < 200
'AddLine(Begin X, Begin Y, End X, End Y)
.ForeColor.RGB = RGB(0, 0, 255)
End With
i = i + 10
Wend

End Sub``````

#### goesr

##### Well-known Member
Hello JugglerJAF - I couldn't resist playing around now that you got me started. Take a look at the code below to draw the imaged figure. All the best.

VBA Code:
``````Sub PatternsWithLinesAll()
Set myDocument = Worksheets(1)
i = 0

While i < 200
'Green - Bottom Right
With myDocument.Shapes.AddLine(200, 10 + i, 200 - i, 200).Line
.ForeColor.RGB = RGB(0, 255, 0)
End With
'Blue - Bottom Left
With myDocument.Shapes.AddLine(10, i + 10, i + 10, 200).Line
.ForeColor.RGB = RGB(0, 0, 255)
End With
'Red - Top Right
With myDocument.Shapes.AddLine(i + 10, 10, 200, i + 10).Line
.ForeColor.RGB = RGB(255, 0, 0)
End With
'Yellow - Top Left
With myDocument.Shapes.AddLine(10, 10 + i, 200 - i, 10).Line
.ForeColor.RGB = RGB(255, 255, 0)
End With
'Wait 1 second
Application.Wait (Now + TimeValue("0:00:01"))
i = i + 10
Wend

End Sub``````

#### Attachments

• LineDrawing.JPG
53.8 KB · Views: 2

Replies
0
Views
172
Replies
0
Views
395
Replies
5
Views
545
Replies
7
Views
4K
Replies
4
Views
190

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,151,766
Messages
5,766,349
Members
425,350
Latest member
procha

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back