title: replace string part only in textbox vba excel
body: <p>Hi all just want to ask if it is possible to replace or delete a part of string in textbox? instead of replacing or removing the whole string it will just remove part of it only . The program will be as below procedure.</p>
  
  <ol>
  <li>A user will key in string or text in a textbox example abc123cd</li>
  <li>in an excel cells have a default value of abc and cd . Let we say abc is in A1 and cd in A2.</li>
  <li>Then those default value in A1 and A2 will remove abc and cd in abc123cd. The output will be 123 in the same textbox. it means before it is abc123cd , after clicking commnad button the result will be 123 only in the same textbox.</li>
  </ol>
  
  <p>Below is my sample vba program. But obviously I cannot find the way to fix the issue just to suit my requirements. Hopefully someone can help. Thank you. </p>
  
  <pre><code>Private Sub CommandButton1_Click()
      Dim myLastRow As Long
      Dim myRow As Long
      Dim myFind As String
      Dim myReplace1 As String
      Dim myReplace2 As String
      Dim sExportFolder, sFN
      Dim rArticleName As Range
      Dim rDisclaimer As Range
      Dim oSh As Worksheet
      Dim oFS As Object
      Dim oTxt As Object
  
      'Specify name of Sheet with list of replacements
      Set myReplaceSheet = Sheets("Sheet2")
  
      'Assuming list of replacement start in column A on row 2, find last entry in list
      myLastRow = myReplaceSheet.Cells(Rows.Count, "A").End(xlUp).Row
  
      Application.ScreenUpdating = False
  
      'Loop through all list of replacments
      For myRow = 2 To myLastRow
          'Get find and replace values (from columns A and B)
          myFind = myReplaceSheet.Cells(myRow, "A")
          myReplace1 = myReplaceSheet.Cells(myRow, "B")
  
          'Start at top of data sheet and do replacements
          myDataSheet.Activate
          Range("A2").Select
  
          'Ignore errors that result from finding no matches
          On Error Resume Next
  
          'Do all replacements 
          With TextBox1
              .Replace What:=myFind, Replacement:=myReplace1, LookAt:=xlPart, _
                SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
                ReplaceFormat:=False
          End With
      Next myRow
  End Sub
  </code></pre>