Results 1 to 5 of 5

ActiveX Combo Box and VBA code not working on multiple Data Validation Dropdown Lists

Threaded View

  1. #1
    Registered User
    Join Date
    08-25-2016
    Location
    Calgary, Canada
    MS-Off Ver
    2010
    Posts
    4

    ActiveX Combo Box and VBA code not working on multiple Data Validation Dropdown Lists

    Hello,

    I'm very new to this and I've been reading and learning from everybody's posts here. To workaround the problem of data validation dropdown list's small font on request form I’m working on, I've come cross to this helpful page http://www.contextures.com/xlDataVal14.html, and I'm quite happy that it works on one of my dropdown lists, but not for all of them. I suspect there is something I need to change in the VBA code but couldn’t find answers on this forum... I'm hoping someone could help me please!

    Some of my data validations are in merged cells and some are in single cells.
    Also, I have a column of data validation which is based on the cell before, and the source formula looks like below.
    =OFFSET(Brands!$B$1,MATCH(A32,Brands!$B:$B,0)-1,1,COUNTIF(Brands!$B:$B,A32),1)

    Any input is greatly appreciated.

    Private Sub TempCombo_KeyDown(ByVal _
            KeyCode As MSForms.ReturnInteger, _
            ByVal Shift As Integer)
        'Hide combo box and move to next cell on Enter and Tab
        Select Case KeyCode
            Case 9
                ActiveCell.Offset(0, 1).Activate
            Case 13
                ActiveCell.Offset(1, 0).Activate
            Case Else
                'do nothing
        End Select
    
    End Sub
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim str As String
    Dim cboTemp As OLEObject
    Dim ws As Worksheet
    Dim Tgt As Range
    Dim TgtMrg As Range
    Dim c As Range
    Dim TgtW As Double
    Dim AddW As Long
    Dim AddH As Long
    
    Set ws = ActiveSheet
    On Error Resume Next
    'extra width to cover drop down arrow
    AddW = 15
    'extra height to cover cell
    AddH = 5
    
    If Target.Rows.Count > 1 Then GoTo exitHandler
    
    Set Tgt = Target.Cells(1, 1)
    Set TgtMrg = Tgt.MergeArea
    On Error GoTo errHandler
    
      Set cboTemp = ws.OLEObjects("TempCombo")
        On Error Resume Next
      If cboTemp.Visible = True Then
        With cboTemp
          .Top = 10
          .Left = 10
          .ListFillRange = ""
          .LinkedCell = ""
          .Visible = False
          .Value = ""
        End With
      End If
    
      On Error GoTo errHandler
      If Tgt.Validation.Type = 3 Then
        Application.EnableEvents = False
        If Not TgtMrg Is Nothing Then
          'get total width of merged cells
          TgtW = 0
          For Each c In TgtMrg.Cells
            TgtW = TgtW + c.Width
          Next c
        End If
        
        str = Tgt.Validation.Formula1
        str = Right(str, Len(str) - 1)
        With cboTemp
          .Visible = True
          .Left = Tgt.Left
          .Top = Tgt.Top
          If TgtW <> 0 Then
            'use total width for merged cells
            .Width = TgtW + AddW
          Else
            .Width = Tgt.Width + AddW
          End If
          .Height = Tgt.Height + AddH
          .ListFillRange = str
          .LinkedCell = Tgt.Address
        End With
        cboTemp.Activate
        Me.TempCombo.DropDown
      End If
    
    exitHandler:
      Application.EnableEvents = True
      Application.ScreenUpdating = True
      Exit Sub
    errHandler:
      Resume exitHandler
    
    End Sub
    Last edited by ringonohitorigoto; 09-29-2016 at 11:09 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Data Validation Combo Box with Multiple Independent Validation Lists
    By firstofnine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2016, 04:38 PM
  2. Data validation referring to an activex combo box?
    By phmdt in forum Excel General
    Replies: 6
    Last Post: 03-09-2016, 07:32 PM
  3. [SOLVED] Autocomplete dropdown list, NOT data validation or ActiveX
    By Phillips Contracting in forum Excel General
    Replies: 7
    Last Post: 03-24-2014, 02:31 PM
  4. Massive Data Validation with Dropdown lists
    By tonalqualityx in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-09-2013, 12:12 PM
  5. Changing code to allow for multiple data validation lists/combo boxes
    By StatsN3rd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-11-2013, 02:12 PM
  6. creating VB code using advanced search criteria with multiple data validation lists?
    By Jonathan Bay in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2011, 09:56 AM
  7. filtering multiple data validation dropdown lists
    By gdallas in forum Excel General
    Replies: 4
    Last Post: 05-12-2010, 03:28 AM

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