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

查看:36
本文介绍了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.

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

解决方案

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天全站免登陆