title: Code to Select the Worksheet using textbox
body: <p>I have a small userform with two textbox in it. What I need is that when I press the submit button it will run a code for me and at the end it should activate the worksheet whose name is entered in textbox2. So far I have gone through all the phases but unable to complete the last step.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>Private Sub CommandButton1_Click()
  'Defining the Variables
  Dim ws As Worksheet
  Dim tbl As ListObject
  Dim row As ListRow
  Dim sample As Worksheet
  
  'Assigning the Variables
  Set ws = UserForm2.txt2.Value
  Set tbl = ws.ListObjects(1)
  Set row = tbl.ListRows.Add(Alwaysinsert:=True)
  
  'Setting Up the Range and Enter Data in Table
  lastrow = ws.Range("A:A").End(xlUp).row
  row.Range(1, 1).Value = txt1.Value
  
  'Create the New Sheet for the Account Head Created
  Sheets("Summary-CH-Sample").Copy After:=Sheets(Sheets.Count)
  Set sample = ActiveSheet
  sample.Name = UserForm2.txt1.Value
  
  'Entering the Sheet name in Newly Created Sheet
  With ActiveSheet
  Range("A7").Value = "Summary of " &amp; UserForm2.txt1.Value
  End With
  </code></pre>
  
  <p>Kindly help me out.</p>
  
  <p>Thanks
  Salman Khan</p>