title: Excel vba histogram bin
body: <p>I'm creating a histogram using VBA. I have data on the "Raw Data" sheet. I can create the chart using the data, then I Cut and Paste it to my "Summary" tab using the code below.</p>
  
  <pre><code>'
  ' Histogram of Entries
  '
  Sheets("Raw Data").Select
  Range("F" &amp; intFirstRow + 1 &amp; ":F" &amp; intLastRow).Select
  ActiveSheet.Shapes.AddChart2(-1, xlHistogram).Select
  Selection.Cut
  Sheets("Summary").Select
  ActiveSheet.Paste
  With ActiveSheet.Shapes("Chart 3")
  ' Reposition the chart
      .IncrementLeft Range("E17").Left
      .IncrementTop Range("E17").Top
  End With
  </code></pre>
  
  <p>What I'm struggling with is that I need to adjust the width of the bins, such that the chart displays the count of items in intervals of 10. I can do this in the un-automated way by</p>
  
  <p>-right-clicking on the chart, then selecting "Format Plot Area",</p>
  
  <p>-in the sidebar that appears, clicking on the "Plot Area Options" drop-down and selecting "Horizontal Axis",</p>
  
  <p>-clicking on the histogram icon, then opening up the drop-down for "Axis Options", then</p>
  
  <p>-clicking on the "Bin Width" item and putting in "10.0".</p>
  
  <p>I tried recording the macro while doing this, but I get nothing in it. Any idea how I can do so using VBA?</p>