title: Runtime Error for Chart Set Source Data in VBA while using Range.Address
body: <p>I'm trying to put the data source from one sheet to the Chart in the other sheet. I'm able to achieve the data collection, but at the end, when we set the Source Data, it is throwing Run time error 1004 - Method 'Range' of object'_Global' failed.</p>
  <p>Following is the code I'm using</p>
  <pre><code>Sub UBCharts()
  
  Set Wb = ThisWorkbook
  Set WsCharts = Wb.Sheets(&quot;Trend Charts&quot;)
  Set UBMainChart = WsCharts.ChartObjects(&quot;UBMainChart&quot;)
  Set UBMonthlyYTDSht = Wb.Worksheets(&quot;UM - Monthly &amp; YTD Trend&quot;)
  YearValue = WsCharts.Range(&quot;A1&quot;).Value
  'LookupDate = CDate(&quot;&quot; &amp; &quot;01/01/&quot; &amp; YearValue &amp; &quot;&quot;)
  
  Xrows = UBMonthlyYTDSht.Range(&quot;A&quot; &amp; Rows.Count).End(xlUp).Row
  MatchStartRow = Application.WorksheetFunction.Match(CLng(CDate(DateSerial(YearValue, 1, 1))), UBMonthlyYTDSht.Columns(&quot;A:A&quot;), 0)
  MatchEndRow = Application.WorksheetFunction.Match(CLng(CDate(DateSerial(YearValue, Month(CLng((DateAdd(&quot;m&quot;, -1, Date)))), 1))), UBMonthlyYTDSht.Columns(&quot;A:A&quot;), 0)
  UBMainChart.Activate
  
  'ActiveChart.SetSourceData Source:=Range(&quot;'UM - Monthly &amp; YTD Trend'!$A$1:$L$1,'UM - Monthly &amp; YTD Trend'!$A$14:$L$23&quot;)
  UBMainChart.Chart.ChartArea.ClearContents
  On Error Resume Next
  UBMonthlyYTDSht.Activate
  Set ChartRange = UBMonthlyYTDSht.Range(Cells(MatchStartRow, 1), Cells(MatchEndRow, Lcols))
  Set ChartRngTitles = UBMonthlyYTDSht.Range(Cells(1, 1), Cells(1, Lcols))
  On Error GoTo 0
  
  UBMainChart.Activate
  RngStr = &quot;&quot;&quot;'&quot; &amp; UBMonthlyYTDSht.Name &amp; &quot;'!&quot; &amp; ChartRngTitles.Address &amp; &quot;,&quot; &amp; &quot;'&quot; &amp; UBMonthlyYTDSht.Name &amp; &quot;'!&quot; &amp; ChartRange.Address &amp; &quot;&quot;&quot;&quot;
  ActiveChart.SetSourceData Source:=Range(RngStr), PlotBy:=xlColumns 'I'm getting error here
  '&quot;'UM - Monthly &amp; YTD Trend'!$A$1:$L$1,'UM - Monthly &amp; YTD Trend'!$A$14:$L$23&quot;
  
  End Sub
  </code></pre>
  <p>Appreciate your help!</p>