VBA Excel Combobox:下拉列表滚动问题 [英] VBA Excel Combobox: drop-down list scrolling issue

查看:4444
本文介绍了VBA Excel Combobox:下拉列表滚动问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行32位Excel 2010.我创建了多个ActiveX控件组合框,他们都在其下拉列表中有多个条目。事情是,而不是使用鼠标点击滚动列表,我想使用鼠标滚动滚动列表,但它实际上不工作。当我在列表中滚动时,它滚动整个列表而不是其中的内容。

解决方案

我使用这种方法来停止列表从组合框中分离并用鼠标滚轮向下移动工作表。它实际上是禁用鼠标滚动,但你仍然可以移动鼠标选择一个项目,并操作右滚动条,如果它出现。


  1. 选择您放置ActiveX组合框和工作表的行

  2. 在公式栏中键入命名范围,然后按Enter键。例如:rngJobRoleCombo

  3. 在开发模式下右键单击控件,然后选择查看代码

  4. 选择控件的GotFocus事件

      Private Sub cboJobRole_GotFocus()
    Me.ScrollArea = Range(rngJobRoleCombos)。 Sub


  5. 选择控制LostFocus事件

      Private Sub cboJobRole_LostFocus()
    Me.ScrollArea =
    End Sub


当控件处于焦点位置时,鼠标滚动到工作表的单元格范围地址。


I am running 32-bit Excel 2010. I have created multiple ActiveX Control combo boxes and they all have numbers of entries in their drop-down lists. The thing is that instead of using mouse click to scroll the list, I want to use the mouse scroll to scroll the list, but it actually doesn't work. When I scroll inside of the list, it scrolls the whole list down instead of the content in it. So does anyone know how to add this feature to it?

解决方案

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.

这篇关于VBA Excel Combobox:下拉列表滚动问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆