title: How to change the source data for a chart in a chart sheet Excel vba
body: <p>all together,</p>
  
  <p>I am trying to create a regional map chart that shows data per country. The data is provided by a dynamic table.
  I created a chart sheet and inserted the regional map chart into it.
  The chart now shows the data for the current countries, but I can't change the data.
  The string mapInput is correct and also shows the right Range.
  For example: "A4293:A4295,BJ4293:BJ4295"</p>
  
  <p>The error 1004 comes up in the last line.</p>
  
  <p>I also tried without "Source:="
  And also without "chart"</p>
  
  <pre><code>    l = Split(ws.Cells(lastRowR, lastColR - 2).Address, "$")(1)
  
      mapInput = "A" &amp; lastRowR - 1 - cCount &amp; ":A" &amp; lastRowR - 1 &amp; "," &amp; l &amp; 
      lastRowR - 1 - cCount &amp; ":" &amp; l &amp; lastRowR - 1
  
      Sheets("map").ChartObjects(1).Chart.SetSourceData Source:=ws.Range(mapInput)
  </code></pre>
  
  <p>Runtime Error 1004 “Application-defined or Object-defined error”</p>