+ Reply to Thread
Results 1 to 3 of 3

ComboBox autofill

Hybrid View

SPARKY347 ComboBox autofill 05-15-2015, 11:10 PM
SPARKY347 Re: ComboBox autofill 05-17-2015, 01:25 AM
LJMetzger Re: ComboBox autofill 06-03-2015, 08:42 PM
  1. #1
    Forum Contributor
    Join Date
    05-02-2015
    Location
    calgary alberta
    MS-Off Ver
    2012
    Posts
    205

    ComboBox autofill

    hey everyone ive created a sheet adding and searching materials, works awesome so far just trying to make adjustments. when I search something I can type in either combo box problem is to search I have to start with the first word to get the combo box to auto complete ex. "single" will produce "single gang ressy box". is there any way to maybe search "gang" and have it produce the full string or any match of the string and I can narrow from there
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    05-02-2015
    Location
    calgary alberta
    MS-Off Ver
    2012
    Posts
    205

    Re: ComboBox autofill

    bump anyone?

  3. #3
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: ComboBox autofill

    Hi Sparky,

    The following code should help you get started. See the attached sample workbook.
    Sub FindAllMatches()
    
      Dim r As Range
      Dim iCount As Long
      Dim iListBoxRow As Long
      Dim iRow As Long
      Dim bNeedMore As Boolean
      Dim sAddress As String
      Dim sFirstAddress As String
      Dim sSearchSpecification As String
      
      If Len(sSearchSpecification) = 0 Then
        sSearchSpecification = Trim(Mat_Search.NmbSearch.Value)
      End If
      
      If Len(sSearchSpecification) = 0 Then
        sSearchSpecification = Trim(Mat_Search.DescSearch.Value)
      End If
      
      If Len(sSearchSpecification) = 0 Then
        sSearchSpecification = Trim(Mat_Search.TextBox3.Value)
      End If
      
      If Len(sSearchSpecification) > 0 Then
      
        Mat_Search.ListBox1.Clear
        iListBoxRow = -1
    
      
        'Find the first occurence of the string
        Set r = Nothing
        Set r = Worksheets("Materials").Range("A:A,C:C,E:E").Find(What:=sSearchSpecification, _
                            After:=Worksheets("Materials").Range("A1"), _
                            LookIn:=xlValues, _
                            LookAt:=xlPart, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False, _
                            SearchFormat:=False)
                          
        If Not r Is Nothing Then
      
          'Save the found address as the 'First Address'
          'Save the value to be returned
          iCount = iCount + 1
          sFirstAddress = r.Address(False, False)
          Debug.Print "First occurrence of '" & sSearchSpecification & "' is in cell '" & sFirstAddress & "'."
          
          'Search for additional values
          'If found add them to the array to be returned
          bNeedMore = True
          While bNeedMore
          
            iRow = r.Row
          
            iListBoxRow = iListBoxRow + 1
            Mat_Search.ListBox1.AddItem
            Mat_Search.ListBox1.List(iListBoxRow, 0) = Trim(Worksheets("Materials").Cells(iRow, "A").Value)
            Mat_Search.ListBox1.List(iListBoxRow, 1) = Trim(Worksheets("Materials").Cells(iRow, "C").Value)
            Mat_Search.ListBox1.List(iListBoxRow, 2) = Trim(Worksheets("Materials").Cells(iRow, "E").Value)
          
          
            Set r = Worksheets("Materials").Range("A:A,C:C,E:E").FindNext(After:=r)
            sAddress = r.Address(False, False)
            If sAddress = sFirstAddress Then
              bNeedMore = False
            Else
              iCount = iCount + 1
              Debug.Print "Next occurrence of '" & sSearchSpecification & "' is in cell '" & sAddress & "'."
            End If
          Wend
        End If
        
      
      
      End If
      
    End Sub
    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel for Mac 2011: ComboBox Autofill
    By wsarij in forum Excel General
    Replies: 2
    Last Post: 12-08-2014, 09:37 PM
  2. Autofill base on Active Cell and Autofill by row count of another sheet
    By enyak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2014, 10:06 PM
  3. Macro for Autofill removes header info when there is no data to autofill
    By esturan in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-06-2012, 01:42 PM
  4. Combobox with autofill across 2 documents
    By bloodnovski in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2012, 05:11 PM
  5. Replies: 1
    Last Post: 06-17-2005, 04:05 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