title: VBA Excel : Populate TextBox with specific string of text when Option Button is selected
body: <p>I developed a Form in Excel (2016) and I am trying (with VBA) to configure its behavior so that if the user selects a particular option button, two additional things happen:</p>
  
  <ol>
  <li>A checkbox further down on the form is automatically checked.</li>
  <li>A text box further down on the form automatically displays a set string of text.</li>
  </ol>
  
  <p>More specifically, if the user selects <em>OptionButtonABC</em>, then ...</p>
  
  <ol>
  <li><em>CheckBoxNone</em> should become checked</li>
  <li><em>TextBoxCompanyName</em> (which does not display any text by default) should now display the string: 'ABC'.</li>
  </ol>
  
  <p>I initially created a subroutine that just targeted condition 1, and everything worked fine. However, when I try to integrate the code required to handle condition 2, things start to unravel.</p>
  
  <p>Below, you will see the code in its most current state. I have a Private Sub that initiates upon the Click event and then immediately defines a variable as a string. I then set up an if/then statement that specifies what should happen IF <em>OptionButtonABC</em> is true. Namely, <em>CheckBoxNone</em> should be selected (this works fine) AND <em>TextBoxCompanyName</em> should now display the string 'ABC'.</p>
  
  <pre><code>Private Sub OptionButtonABC_Click()
  Dim Variable_ABC As String
  Variable_ABC = ABC
  If Me.OptionButtonABC.Value = True Then
  Me.CheckBoxNone = True And Me.TextBoxCompanyName.Text = Variable_ABC
  End If
  End Sub
  </code></pre>
  
  <p>The desired behavior should (theoretically) be pretty easy to achieve, but my experience with VBA is still pretty limited, so I am reaching out to the community for a bit of advice. As I mentioned above, the code above works for the first condition. However, I am still unable to get the string of text ('ABC') to show up in the text box.</p>
  
  <p>Thanks in advance for any advice you may offer.</p>