title: Graphs with various Y values and one X values in Excel VBA
body: <p>This is the code i use to create a graph which searches for .csv {created using excel application} file in the path specified. It plots the column 'B' { Y axis } against column 'C' {X-axis}.. I want to one more column 'A' to my Y axis keeping column 'C' as the X axis.. How can i do that???</p>
  
  <p>here is the code...</p>
  
  <pre><code>Sub Draw_Graph()
      Dim strPath As String
      Dim strFile As String
      Dim strChart As String
      Dim i As Integer
      Dim j As Integer
  
      strPath = "C:\PortableRvR\report\"
      strFile = Dir(strPath &amp; "*.csv")
      i = 1
  
      Do While strFile &lt;&gt; ""
          With ActiveWorkbook.Worksheets.Add
              With .QueryTables.Add(Connection:="TEXT;" &amp; strPath &amp; strFile, _
                  Destination:=.Range("A1"))
                  Parent.Name = Replace(strFile, ".csv", "")
                  TextFileParseType = xlDelimited
                  TextFileTextQualifier = xlTextQualifierDoubleQuote
                  TextFileConsecutiveDelimiter = False
                  TextFileTabDelimiter = False
                  TextFileSemicolonDelimiter = False
                  TextFileCommaDelimiter = True
                  TextFileSpaceDelimiter = False
                  TextFileColumnDataTypes = Array(1)
                  TextFileTrailingMinusNumbers = True
                  Refresh BackgroundQuery:=False
                  Files(i) = .Parent.Name
                  i = i + 1
              End With
          End With
          strFile = Dir
      Loop
  
      numOfFiles = i - 1
      chartName = "Chart 1"
  
      For j = 1 To numOfFiles
          strFile = Files(j)
          Sheets(strFile).Select
          Plot_y = Range("B1", Selection.End(xlDown)).Rows.Count
          Plot_x = Range("C1", Selection.End(xlDown)).Rows.Count
  
          Sheets("GraphDisplay").Select
          If j = 1 Then ActiveSheet.ChartObjects(chartName).Activate
          ActiveChart.SeriesCollection.NewSeries
          ActiveChart.SeriesCollection(j).Name = strFile
          ActiveChart.SeriesCollection(j).XValues = Sheets(strFile).Range("C1:C" &amp; Plot_x)
          ActiveChart.SeriesCollection(j).Values = Sheets(strFile).Range("B1:B" &amp; Plot_y)
          ActiveChart.SeriesCollection(j).MarkerStyle = -4142
          ActiveChart.SeriesCollection(j).Smooth = False
      Next j
  
      ActiveSheet.ChartObjects(chartName).Activate
      ActiveChart.Axes(xlValue).DisplayUnit = xlMillions
      ActiveChart.Axes(xlValue).HasDisplayUnitLabel = False
  End Sub
  </code></pre>