Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-12-2019, 07:53 AM
NoSparks NoSparks is offline How to filter data before it is pulled into combobox/listbox AND remove data from listbox Windows 7 64bit How to filter data before it is pulled into combobox/listbox AND remove data from listbox Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default


For your first point, try changing the CompanyName MatchRequired to False and using CompanyName_BeforeUpdate to check for match.
Code:
Private Sub CompanyName_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
    Dim myString As String
    Dim i As Long
    Dim strFound As Boolean

'check if combobox value exists in .list
myString = Me.CompanyName.Text
strFound = False
With Me.CompanyName
     'Loop through combobox list
    For i = 0 To .ListCount - 1
        If .List(i) = myString Then
            strFound = True
            Exit For
        End If
    Next i
End With
    
If Not strFound Then
    'entry does not exist
    If Len(myString) > 0 Then
        MsgBox "The entered value is not in the list"
        Cancel = True   'keeps you in the combo
        Me.CompanyName = ""
        Exit Sub
    Else
        'clear the call history
        Me.CallHistory.Clear
        Exit Sub
    End If
Else
    'entry exists
    Call CompanyName_Click
End If

End Sub
Reply With Quote
  #2  
Old 05-13-2019, 08:46 AM
Izzii0x Izzii0x is offline How to filter data before it is pulled into combobox/listbox AND remove data from listbox Windows 10 How to filter data before it is pulled into combobox/listbox AND remove data from listbox Office 2016
Novice
How to filter data before it is pulled into combobox/listbox AND remove data from listbox
 
Join Date: May 2019
Posts: 13
Izzii0x is on a distinguished road
Default

Thanks! This works perfectly!! Much appreciated.

Don't suppose you have any other genius ideas for the other points?
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to filter data before it is pulled into combobox/listbox AND remove data from listbox Listbox or Combobox population wannaExcel Excel Programming 4 04-06-2019 02:53 PM
Add-In creates ListBox from XLS, but data not saved in ppt barbet PowerPoint 0 05-26-2016 02:30 AM
This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel Programming 14 08-18-2014 08:14 PM
How to filter data before it is pulled into combobox/listbox AND remove data from listbox This is a Userform LIstbox queston: A variable does not set to the value of a listbox CatMan Excel 1 08-08-2014 09:41 AM
Data from Excel to Listbox multiselect to Word marksm33 Word VBA 2 02-18-2014 08:30 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:18 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft