Closed Thread
Results 1 to 3 of 3

Excel Combo box search drop down list

Hybrid View

Mathewj Excel Combo box search drop... 04-17-2016, 04:59 AM
AliGW Re: Excel Combo box search... 04-17-2016, 05:05 AM
Mathewj Re: Excel Combo box search... 04-17-2016, 05:18 AM
  1. #1
    Registered User
    Join Date
    07-13-2015
    Location
    sydney
    MS-Off Ver
    windows 7
    Posts
    8

    Excel Combo box search drop down list

    Hello VBA Masters,
    The below is a code which is from this website. it makes a datasheet with drop down list into a search and fill form by using a combo box. The code works for both the drown down formulas . i.e. it works when I use’ named range’ field and also an INDIRECT($A$2) formula. The problem I have is that the code goes through the whole spreadsheet and looks for EVERY dropdown in the sheet and it becomes an issue at times – especially when I have use a data field as a drop down list.
    Can I get the code to only work for certain cells? – For example I want it to work for Whole column B and C and D. but the remaining sheet should be normal dropdown boxes.
    Your help would be much appreciated.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim sh1 As Worksheet
    Dim sh2 As Worksheet
    Dim sh3 As Worksheet
    'Dim wslist As Worksheet
    Set ws = ActiveSheet
    
    
    Set sh1 = ActiveWorkbook.Sheets("lookupdata")
    Set sh2 = ActiveWorkbook.Sheets("loccountries")
    Set sh3 = ActiveWorkbook.Sheets("loccities")
    
    Set cboTemp = ws.OLEObjects("TempCombo")
      On Error Resume Next
    If cboTemp.Visible = True Then
      With cboTemp
        .ListFillRange = ""
        .LinkedCell = ""
        .Visible = False
        .Value = ""
      End With
    End If
    
      On Error GoTo errHandler
      If Target.Validation.Type = 3 Then
        'if the cell contains a data validation list
        Application.EnableEvents = False
        'get the data validation formula
        str = Target.Validation.Formula1
        If Left(str, Len("=INDIRECT(")) = "=INDIRECT(" Then
            str = Mid(str, Len("=INDIRECT(") + 1)
            str = Left(str, Len(str) - 1)
            str = Evaluate(str)
            strAddress = "'" & Application.Names(str).RefersToRange.Parent.Name & "'!" & _
                         Application.Names(str).RefersToRange.Address
        Else
            str = Right(str, Len(str) - 1)
            strAddress = str
        End If
        With cboTemp
          'show the combobox with the list
          .Visible = True
          .Left = Target.Left
          .Top = Target.Top
          .Width = Target.Width + 15
          .Height = Target.Height + 5
          .ListFillRange = strAddress
          .LinkedCell = Target.Address
        End With
        cboTemp.Activate
      End If
    
    exitHandler:
      Application.ScreenUpdating = True
      Application.EnableEvents = True
      Exit Sub
    errHandler:
      Resume exitHandler
    
    End Sub
      
      
    Private Sub TempCombo_KeyDown(ByVal _
            KeyCode As MSForms.ReturnInteger, _
            ByVal Shift As Integer)
      'change text value to number, if possible
      On Error Resume Next
      
      Select Case KeyCode
        Case 9 'Tab - change text to number, move right
          ActiveCell.Value = --ActiveCell.Value
          ActiveCell.Offset(0, 1).Activate
        Case 13 'Enter - change text to number, move down
          ActiveCell.Value = --ActiveCell.Value
          ActiveCell.Offset(1, 0).Activate
        Case Else
            'do nothing
      End Select
    End Sub

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,492

    Re: Excel Combo box search drop down list

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. Please continue in your other thread.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-13-2015
    Location
    sydney
    MS-Off Ver
    windows 7
    Posts
    8

    Re: Excel Combo box search drop down list

    HI Ali,
    I cant edit or reply to my earlier also i cant delete it.

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Excel Combo box search drop down list
    By Mathewj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-17-2016, 01:56 PM
  2. how to create search suggestion drop down list in mac excel
    By sumit978 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 05-07-2015, 02:52 AM
  3. Excel Drop Down list with Search Suggestions against Auto Generate Serial Number
    By silambarasan.J in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-22-2015, 04:27 AM
  4. how to use combo box in macbook pro excel for drop down suggestion list
    By sumit978 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-12-2014, 08:07 AM
  5. [SOLVED] Combo Box Search and list down
    By acrylic26 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-20-2013, 08:33 PM
  6. [SOLVED] Combo Box (drop down list)
    By cmf0106 in forum Excel General
    Replies: 7
    Last Post: 11-15-2012, 01:33 PM
  7. How do I create a combo drop down list in Excel?
    By Ron in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-15-2005, 04:06 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