Results 1 to 3 of 3

Search with Criteria on Userform

Threaded View

  1. #1
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    206

    Search with Criteria on Userform

    Please advice how can I make Search with Criteria on Userform zie below macro
    I appreciate beforehand your attention and time.


    Sub SearchBox()
    
    Dim myButton As OptionButton
    Dim SearchString As String
    Dim ButtonName As String
    Dim sht As Worksheet
    Dim myField As Long
    Dim DataRange As Range
    Dim mySearch As Variant
    
    
      Set sht = ActiveSheet
    
    
      On Error Resume Next
        sht.ShowAllData
      On Error GoTo 0
      
    
      Set DataRange = sht.Range("A4:E160") 'Cell Range
      
    
    
      mySearch = sht.Shapes("Search").TextFrame.Characters.Text 'Control Form
     
      If IsNumeric(mySearch) = True Then
        SearchString = "=" & mySearch
      Else
        SearchString = "=*" & mySearch & "*"
      End If
        
    
      For Each myButton In sht.OptionButtons
        If myButton.Value = 1 Then
          ButtonName = myButton.Text
          Exit For
        End If
      Next myButton
       
    
      myField = Application.WorksheetFunction.Match(ButtonName, DataRange.Rows(1), 0)
       
    
      DataRange.AutoFilter _
        Field:=myField, _
        Criteria1:=SearchString, _
        Operator:=xlAnd
      
    
      sht.Shapes("Search").TextFrame.Characters.Text = "" 'Control Form
      
      
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Userform search 3 criteria
    By adamheon in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-29-2016, 03:02 PM
  2. Userform search from sheet and find criteria and sum
    By konficus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-04-2015, 10:02 AM
  3. Create a search userform to search using multiple criteria
    By Aleemaher in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-31-2014, 09:17 AM
  4. [SOLVED] ListBox to populate UserForm trouble with same search criteria
    By chriswhite1982 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 06-10-2014, 01:46 AM
  5. Userform To search based on 2 criteria Help
    By MDJ666 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2013, 09:29 AM
  6. Userform Multi Criteria search
    By winkypinky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-10-2012, 04:41 PM
  7. Userform Search Criteria
    By timarcarze in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-14-2011, 11:35 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1