拖拉时Excel滚动条用户窗体不会持续更新 [英] Excel Scroll Bar User Form won't Continuously Update when Dragged

查看:424
本文介绍了拖拉时Excel滚动条用户窗体不会持续更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个电子表格,它将利用一个带有滚动条的用户表单。我需要滚动条来更新实时指定的单元格,因为我使用鼠标拖动条,目前它只调整值在单元格当我释放鼠标。

I am designing a spreadsheet that will utilise a user form with a scroll bar on it. I need to scroll bar to update the cell specified in real time as I drag the bar using the mouse, at present it only adjusts the value In the cell when I release the mouse.

我最初想使用滑块,但从研究看来,这些滑块不能在用户窗体中使用。

I initially wanted to use a slider but from research it appears that these can't be used in a userform.

有没有人知道任何VBA代码或任何会使滚动条不断更新,因为我使用鼠标拖动酒吧?

Does anyone know any VBA code or anything that will make the scroll bar continuously update as I drag the bar using the mouse?

推荐答案

如果您在用户窗体中使用滚动条,并希望在拖动时进行更新,则需要将代码放在滚动条的滚动事件处理程序。您所描述的行为发生在滚动条的更改事件处理程序。要查看差异,请使用滚动条创建一个新的用户窗体,作为唯一的控件。在其代码模块中,输入以下两个事件处理程序。当你运行它应该看到B1但不是A1更新顺利:

If you are using the scroll bar on a userform and you want the update to be while dragging you need your code to be in the scroll bar's scroll event handler. The behavior that you descried happens with the scroll bar's change event handler. To see the difference, create a new userform with a scroll bar as the only control on it. In it's code module enter the following two event-handlers. When you run it you should see B1 but not A1 updating smoothly:

Private Sub ScrollBar1_Change()
    Range("A1").Value = ScrollBar1.Value
End Sub

Private Sub ScrollBar1_Scroll()
    Range("B1").Value = ScrollBar1.Value
End Sub

这篇关于拖拉时Excel滚动条用户窗体不会持续更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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