title: Define a control caption on a form in vba using a variable to define the control
body: <p>Please let me start again.</p>
  
  <p>I have a  user form,SortForm that has 30 radio buttons on it.  The purpose of the form is to allow the user to pick one of the buttons to use as a key to sort the spreadsheet.  It is sorting on courses and these change for each registration period. </p>
  
  <p>What I am attempting to do is change the captions of radio buttons to reflect the course names. I have store the information from the spreadsheet into two arrays,strSortName and intSortCol.  strSortName contains the course name.  Each radio buttons name starts with "btSort" and then a number 1 to 30. What I want to do is using the concatenation of "btsort" and the index from my do loop to update the caption of the button to reflect the course name contain in strSortName   </p>
  
  <p>I hope this is a better question</p>
  
  <p>Charley</p>
  
  <p><strong>Code to date , Stuck on updating Captions</strong></p>
  
  <p>Sub macSortData()
  '
  ' macSortData Macro
  '
  ' Keyboard Shortcut: Ctrl+Shift+S
  '</p>
  
  <p>Dim strVal1 As String, intVal2 As Integer, I As Integer
  Dim FormName As String ' not sure is needed 
  Dim ControlName As Controls ' not sure if this is needed or correct
  Dim intSortCol(34), strSortName(34) As String</p>
  
  <p>Sheets("Main").Activate</p>
  
  <p>For I = 1 To 34</p>
  
  <p>''strVal1 contains the course name and strVal2 contains the column number for the course</p>
  
  <pre><code>strVal1 = Cells(4, I + 2).Value
  intVal2 = I + 2
  </code></pre>
  
  <p>'tests for ending list of classes</p>
  
  <pre><code> If Len(strVal1) = 0 Then GoTo sortFinal
   If strVal1 = "# taken" Then GoTo sortFinal
  </code></pre>
  
  <p>'stores the name and column number in arrays<br>
          strSortName(I) = strVal1
          intSortCol(I) = intVal2</p>
  
  <p><em>'non working caption update code</em>
  Set ControlName = "btsort" &amp; Trim(str(I)) ' concatenated control name </p>
  
  <p>SortForm.ControlName.Caption = strSortName(I) 'non-working assignment attempt</p>
  
  <p>Next I</p>
  
  <p>sortFinal:</p>
  
  <p>'Display form
      SortForm.Show</p>
  
  <p>End Sub</p>