title: Creating chart with horizontal line
body: <p>I have a sheet , where I have a pivot table. From the pivot table, I am generating chart. My sheet consist of two pivot table and  two charts respectively. </p>
  
  <p>From the pivot table, from my column field "Target", I would like to draw a horizontal line on the value. Could some one help me, how I can mention the range and draw a horizontal line for my column field target. I searched through net, I could not find mentioning the range for a pivot table.</p>
  
  <p>Also, I get an automation error in my Source data in the line</p>
  
  <blockquote>
    <p><code>.SetSourceData pt</code></p>
  </blockquote>
  
  <p>Below Is the code I am using to generate my chart from pivot table</p>
  
  <pre><code>Sub chart()
  Dim cht As Chart
  Dim stable As PivotTable
  Dim pt, sh
  
        If ActiveSheet.PivotTables.count = 0 Then Exit Sub
           Set stable = ActiveSheet.PivotTables(2)
           Set pt = stable.TableRange1
           Set sh = ActiveSheet.ChartObjects.Add(Left:=250, _
           Width:=400, Top:=20, Height:=250)
           sh.Select
           Set cht = ActiveChart       
                With cht
                 .SetSourceData pt
                 .ChartType = xlColumnStacked
                End With
           cht.FullSeriesCollection(1).Name = "Average of Red"
           cht.SeriesCollection(1).HasDataLabels = True
           cht.SeriesCollection(2).HasDataLabels = True
           cht.SeriesCollection(1).Format.Fill.ForeColor.RGB = RGB(0, 255, 0)
           cht.SeriesCollection(2).Format.Fill.ForeColor.RGB = RGB(255, 0, 0)
           cht.HasTitle = True
           cht.ChartTitle.Text = " Result 2017"
  End Sub
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/18Kv8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/18Kv8.png" alt="This is how I would like to have my chart. But with the title"></a></p>
  
  <p><a href="https://i.stack.imgur.com/liJws.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/liJws.png" alt="this is how my second Pivot table look like. And from the column Target I would like to have the horizontal line"></a></p>