Advertisement
Guest User

Untitled

a guest
May 11th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.43 KB | None | 0 0
  1. Sub MyMacro()
  2.     Dim rng As Range
  3.     Dim plot As Chart
  4.     Set rng = Sheets(1).UsedRange
  5.     Dim x As Range
  6.     Dim y As Range
  7.     Set x = rng.Columns("A")
  8.     Set y = rng.Columns("B")
  9.     Set plot = Charts.Add
  10.     plot.ChartType = xlXYScatter
  11.     Dim s As Series
  12.     Set s = plot.SeriesCollection.NewSeries()
  13.     s.XValues = x
  14.     s.Values = y
  15.     Dim t As Trendlines
  16.     Set t = s.Trendlines
  17.     t.Add xlLinear
  18. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement