title: creating a scatter plot containing series dynamically using VBA in microsoft excel
body: <p>I am rather new to VBA so I would appreciate more thorough explanations of what you did to solve this minor issue.</p>
  
  <p>I am tasked with creating a simple VBA program that takes an already sorted set of data (I learned about it and then used a VBA program to sort my data alphabetically already based on a particular column's values) and does the following two things with it:</p>
  
  <ol>
  <li>Graphs a scatter plot with it (either within that sheet or in a separate sheet)</li>
  </ol>
  
  <p>AND</p>
  
  <ol start="2">
  <li>Creates series with that scatter plot dynamically (meaning that scatter plot has series on it based on a particular column's value). I will not know how many series I need but I do know that since it's sorted, the column defining the type of data in that row will be in alphabetical order (and I assume the VBA program can first create a series with the first row's name and then not create more series until it finds a different name in that column until it is finished graphing the data)</li>
  </ol>
  
  <p>an example of a simple 3 column table is shown below: </p>
  
  <p>SERIES NAME ___X VALUE_____Y VALUE</p>
  
  <p>A__________________1___________1</p>
  
  <p>A__________________2___________2</p>
  
  <p>A__________________3___________3</p>
  
  <p>A__________________4___________4</p>
  
  <p>B__________________5___________5</p>
  
  <p>B__________________6___________6</p>
  
  <p>B__________________7___________7</p>
  
  <p>C__________________8___________8</p>
  
  <p>C__________________9___________9</p>
  
  <p>C__________________1___________1</p>
  
  <p>(there could be more rows and more unique series names of course... )</p>
  
  <p>so in this example, the graph is already sorted and I would like there to be a scatter plot with 3 series on it (A being the 1st, B being the 2nd, and 3 being the 3rd)</p>
  
  <p>I have the code to create a scatter plot with one series so far but I've been stuck trying to figure this out (code shown below). Any help with explanation  is greatly appreciated :D</p>
  
  <p>Here's my code so far (without the dynamic series part ofc)</p>
  
  <pre><code>Sub creatingmyscatterplot()
  
  'Dim aRng As Range
  'Dim seriescheck As Range
  Dim Chart1 As Chart
  Set Chart1 = Charts.Add
  
  'Set aRng = Selection.CurrentRegion
  'Set aRng = aRng.Offset(1, 0).Resize(aRng.Rows.Count - 1)
  'Set seriescheck = aRng.Resize(aRng.Rows.Count, 1)
  
  'Dim seriesName As String, seriesData As Range
  'These lines, as their names suggest, turn off screen refresh and recalculating the workbook's formulas before running the macro.
  Application.ScreenUpdating = False
  Application.Calculation = xlCalculationManual
  
  
  With Chart1
  
      .ChartType = xlXYScatterLines
      .SeriesCollection.NewSeries
  
      'This creates the graph
      .SeriesCollection(1).Name = "=Sheet1!$A$2"
      .SeriesCollection(1).XValues = "=Sheet1!$B$2:$B$26001"
      .SeriesCollection(1).Values = "=Sheet1!$C$2:$C$26001"
  
  
      'Titles
      .HasTitle = True
      .ChartTitle.Characters.Text = "X vs. Y"
      .Axes(xlCategory, xlPrimary).HasTitle = True
      .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "SOME TEXT"
      .Axes(xlValue, xlPrimary).HasTitle = True
      .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "SOME TEXT AS WELL"
      .Axes(xlCategory).HasMajorGridlines = True
  
      'Formatting
      .Axes(xlCategory).HasMinorGridlines = False
      .Axes(xlValue).HasMajorGridlines = True
      .Axes(xlValue).HasMinorGridlines = False
      .HasLegend = False
      .Axes(xlValue).MaximumScale = 100
      .Axes(xlValue).MinimumScale = 0
  
  End With
  
  
  'These lines, as their names suggest, turn off screen refresh and recalculating the workbook's formulas before running the macro.
  Application.ScreenUpdating = True
  Application.Calculation = xlCalculationAutomatic
  End Sub
  </code></pre>
  
  <p>Sorry about the indentation of the first and last lines. I just wanted those lines to be in the code block instead of outside it.</p>
  
  <p>THANKS :D</p>