Consulting

Results 1 to 4 of 4

Thread: Modify macro to output to Combobox

  1. #1

    Modify macro to output to Combobox

    I have a macro that searches a textbox for diseases listed in a range (acty sheet column A). Is there a way I can output the results to 1) combo box, 2) listbox, or 3) on the existing sheet. I want three different examples so I know how to deal with them in the future. Attached is the representative sample. Hope someone can help me.

    Public Sub T()
      Dim sSentence As String
      Dim s As Variant
      Dim sDict As Variant
      Dim last As Long
    
      last = Sheets("Acty").Range("A65536").End(xlUp).Row
      
      sDict = Sheets("Acty").Range("A1:A" & last)
    
      sSentence = Sheets("GUI").TextBox1
      
      For Each s In sDict
        If InStr(1, sSentence, Trim$(s), VbCompareMethod.vbTextCompare) > 0 Then
          MsgBox s
        Else
      
        End If
      Next
    
    End Sub
    Attached Files Attached Files

  2. #2
    In codemodule of Sheet1:

    Sub M_snb()
         sn = Sheet1.Cells(1).CurrentRegion
         c00 = Sheets("GUI").TextBox1
      
         For j = 1 To UBound(sn)
             If InStr(c00, sn(j, 1)) Then c01 = c01 & vbLf & sn(j, 1)
         Next
    
         MsgBox c01
    End Sub

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,877
    See attached.
    Attached Files Attached Files
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Wow p45cal. You are Heaven-sent. This is exactly what I need. Thanks also snb as always

Posting Permissions

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