title: Wanting to create a search field and button to trigger VBA script to run
body: <p>I currently have a script which searches through a directory of .csv files to see if it contains a particular string I am looking for.  What I would like to do is pair up this script with a text entry box and button (sort of like a search engine) and save it in an excel file, so any of my coworkers can just open it, search for what they need and click go/search, without any need to modify the VBA code.
  Here is the code I have thus far:</p>
  
  <pre><code>Sub SearchFolders()
      Dim fso As Object
      Dim fld As Object
      Dim strSearch As String
      Dim strPath As String
      Dim strFile As String
      Dim wOut As Worksheet
      Dim wbk As Workbook
      Dim wks As Worksheet
      Dim lRow As Long
      Dim rFound As Range
      Dim strFirstAddress As String
  
      On Error GoTo ErrHandler
      Application.ScreenUpdating = False
  
      'Change as desired
      strPath = "C:\where-im-searching\"
      strSearch = "what I'm Searching"
  
      Set wOut = Worksheets.Add
      lRow = 1
      With wOut
          .Cells(lRow, 1) = "Workbook"
          .Cells(lRow, 2) = "Worksheet"
          .Cells(lRow, 3) = "Cell"
          .Cells(lRow, 4) = "Text in Cell"
          Set fso = CreateObject("Scripting.FileSystemObject")
          Set fld = fso.GetFolder(strPath)
  
          strFile = Dir(strPath &amp; "\*.csv*")
          Do While strFile &lt;&gt; ""
              Set wbk = Workbooks.Open _
                (Filename:=strPath &amp; "\" &amp; strFile, _
                UpdateLinks:=0, _
                ReadOnly:=True, _
                AddToMRU:=False)
  
              For Each wks In wbk.Worksheets
                  Set rFound = wks.UsedRange.Find(strSearch)
                  If Not rFound Is Nothing Then
                      strFirstAddress = rFound.Address
                  End If
                  Do
                      If rFound Is Nothing Then
                          Exit Do
                      Else
                          lRow = lRow + 1
                          .Cells(lRow, 1) = wbk.Name
                          .Cells(lRow, 2) = wks.Name
                          .Cells(lRow, 3) = rFound.Address
                          .Cells(lRow, 4) = rFound.Value
                      End If
                      Set rFound = wks.Cells.FindNext(After:=rFound)
                  Loop While strFirstAddress &lt;&gt; rFound.Address
              Next
  
              wbk.Close (False)
              strFile = Dir
          Loop
          .Columns("A:D").EntireColumn.AutoFit
      End With
      MsgBox "Done"
  
  ExitHandler:
      Set wOut = Nothing
      Set wks = Nothing
      Set wbk = Nothing
      Set fld = Nothing
      Set fso = Nothing
      Application.ScreenUpdating = True
      Exit Sub
  
      ErrHandler:
      MsgBox Err.Description, vbExclamation
      Resume ExitHandler
      End Sub
  </code></pre>
  
  <hr>
  
  <p>So, I would like whatever is entered into the text entry box to be used for strSearch and then when the user clicks the button, it will trigger the above to run &amp; search for whatever has been entered.</p>
  
  <p>Thanks!</p>