title: I have to run my macro twice for it to be correct
body: <p>I created a macro in Excel which iterates through every worksheet - converting text into numbers and then creating a graph from the data. I need to run my macro twice for it to work. </p>
  
  <p>The 1st time, only the graph for the 1st sheet is correct. For the other tabs, all the text is converted to numbers, but the graphs are not mapping to the right data.</p>
  
  <p>The 2nd time I run the macro, everything is as it should be.</p>
  
  <pre><code>Sub UCS_Inventory_Mac1()
  
  Dim I As Integer
  Dim WS_Count As Integer
  
  WS_Count = ActiveWorkbook.Worksheets.Count + 1
  
  For I = 1 To WS_Count
  
      Range("B2:H15").Select
          With Selection
          Selection.NumberFormat = "General"
          .Value = .Value
      End With
  
      If I = 1 Then
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$E$4")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 1"
  
      ElseIf I = 2 Then
          Worksheets("Sheet2").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet2!$A$1:$B$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 2"
  
      ElseIf I = 3 Then
          Worksheets("Sheet3").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet3!$A$1:$D$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 3"
  
      ElseIf I = 4 Then
          Worksheets("Sheet4").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet4!$A$1:$D$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 4"
  
      ElseIf I = 5 Then
          Worksheets("Sheet5").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet5!$A$1:$D$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 5"
  
      ElseIf I = 6 Then
          Worksheets("Sheet6").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet6!$A$1:$C$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 6"
  
      ElseIf I = 7 Then
          Worksheets("Sheet7").Activate
          Range("B2").Select
          ActiveSheet.Shapes.AddChart2(201, xlColumnClustered).Select
          ActiveChart.SetSourceData Source:=Range("Sheet7!$A$1:$B$11")
          ActiveChart.SetElement (msoElementDataLabelOutSideEnd)
          ActiveChart.SetElement (msoElementLegendBottom)
          ActiveChart.SetElement (msoElementLegendTop)
          ActiveChart.ChartTitle.Text = "Chart 7"
  
  End If
  
  Next I
  
  End Sub
  </code></pre>