title: Iterate through a String array and assign the value to Worksheet
body: <p>I am fairly new to VBA, so pardon for any silly mistakes. </p>
  
  <p>I have the names of my worksheets in an array. I am trying to go to each of the worksheets in the array by using the following:</p>
  
  <pre><code>Set ws = Worksheets(listBoxValuesArray(arrayIndex))
  </code></pre>
  
  <p>But I get the error message saying "Subscript out of Range"</p>
  
  <p>I also tried this:</p>
  
  <pre><code>Sheets.Select (listBoxValuesArray(arrayIndex))
  </code></pre>
  
  <p>When I print the <code>listBoxValuesArray(arrayIndex)</code> I am getting the values</p>
  
  <p>Here is the complete for loop</p>
  
  <pre><code>Dim arraySize As Integer
  arraySize = jobSheetsDisplay.ListCount
  Dim listBoxValuesArray() As Variant
  Dim listBoxArrayIndex As Integer
  Dim arrayValue As Variant
  Dim listBoxIndex As Integer
  Dim arrayIndex As Integer
  Dim ws As Worksheet
  ReDim listBoxValuesArray(arraySize)
  listBoxArrayIndex = 0
  For listBoxIndex = 0 To jobSheetsDisplay.ListCount - 1
      If jobSheetsDisplay.Selected(listBoxIndex) Then
      listBoxValuesArray(listBoxArrayIndex) = CStr(jobSheetsDisplay.List(listBoxIndex))
      listBoxArrayIndex = listBoxArrayIndex + 1
     End If
  Next listBoxIndex
  For arrayIndex = 0 To UBound(listBoxValuesArray) 
  Set ws = Worksheets(listBoxValuesArray(arrayIndex)) '
  MsgBox (listBoxValuesArray(arrayIndex))
  Next arrayIndex
  </code></pre>
  
  <p>Basically, I get the values into the array from a list box in a form. The array is defined as a variant type and so is the array index. </p>
  
  <p>Thanks for any help</p>