VBA Excel Combobox: drop-down list scrolling issue

不打扰是莪最后的温柔 提交于 2019-12-04 16:21:16
Neil

I used this method to stop the list detaching from the combo box and moving down the sheet with the mouse scroll. It actually disables the mouse scroll, but you can still move the mouse to select an item, and operaton the right scroll bar if it appears.

  1. Select the row(s) where you have placed the ActiveX combo Box and the sheet
  2. Type a named range in the Formula Bar, and press enter. eg: "rngJobRoleCombo"
  3. Right click on the control in Development mode, and select "View Code"
  4. Select the control's GotFocus event

    Private Sub cboJobRole_GotFocus()
        Me.ScrollArea = Range("rngJobRoleCombos").Address  
    End Sub
    
  5. Select the controls LostFocus event

    Private Sub cboJobRole_LostFocus()
        Me.ScrollArea = ""
    End Sub
    

This limits the mouse scroll to the cell range address of the worksheet while the control is in focus.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!