title: Changing x-axis of a ChartObject in VBA
body: <p>If I want to change my x-axis to the data inside the range <code>G5:G105</code> over <code>Chart 2</code> then I put this into my VBA subroutine: </p>
  
  <pre><code>ActiveSheet.ChartObjects("Chart 2").Activate
  ActiveChart.SeriesCollection(1).XValues = "='Q1'!$G$5:$G$105"
  </code></pre>
  
  <p>How do I make it such that I can have some arbitrary range INSTEAD OF the fixed <code>$G$5:$G$105</code>. I've tried to use </p>
  
  <pre><code>ActiveChart.SeriesCollection(1).XValues = "='Q1'!Range("G5").Resize(I, 1)"
  </code></pre>
  
  <p>where <code>I</code> is some <code>Integer</code> variable defined in a preceding part of the subroutine.</p>
  
  <p>However it doesn't work.</p>