title: How to create a dynamic charts with specific column inputs using vba?
body: <p>I'm trying to create a chart using VBA using the following code:</p>
  
  <pre><code>lr = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
  lc = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
  Set chtRng = Range(Cells(1, 1), Cells(lr, lc))
  ActiveSheet.Shapes.AddChart2(227, xlLine).Select
  ActiveChart.SetSourceData Source:=chtRng
  ActiveChart.SetElement (msoElementLegendBottom)
  Set targetSht = ThisWorkbook.Worksheets("Test_graph")
  </code></pre>
  
  <p>The data is fetched from the database and the data gets flushed in A to D columns.<a href="https://i.stack.imgur.com/2yfMk.png" rel="nofollow noreferrer">Data</a>
  While generating the graph using the above code, I get the following result:<a href="https://i.stack.imgur.com/YA3Gn.png" rel="nofollow noreferrer">Current Results</a>
  But, out of the fetched data, i want to skip the data in the column C and expect a result something like<a href="https://i.stack.imgur.com/q2fvJ.png" rel="nofollow noreferrer">Expected Results</a></p>
  
  <p>Any sort of suggestion or solution is appreciated.</p>
  
  <p>Regards.</p>
  
  <p>PS: I'm new to this platform so kindly excuse me for the formatting.</p>