VBA如何在单元格正下方显示UserForm? [英] VBA How to display UserForm right under the cell?

查看:71
本文介绍了VBA如何在单元格正下方显示UserForm?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在放置在单元格中的按钮的正下方显示UserForm,以便它可以模拟某些弹出窗口(就像下拉列表一样).

I want to display UserForm right under the button that is placed in cell so it can simulate some popup window (just like dropdown list).

我在网上尝试了许多解决方案,但没有一个起作用.主要问题是我无法获得工作表或按钮在工作表上的绝对屏幕位置.

I tried many solutions over the net and none of them worked. The main problem is I'm not able to get the absolute screen location of cell or button on sheet.

推荐答案

您将使用以下逻辑:

Sub SO()

With UserForm1
    .StartUpPosition = 0
    .Top = Application.Top + (ActiveSheet.Shapes(Application.Caller).Top + 170)
    .Left = Application.Left + (ActiveSheet.Shapes(Application.Caller).Left + 25)
    .Show
End With

End Sub

然后您的按钮将调用子 SO()

And your button would call the sub SO()

这篇关于VBA如何在单元格正下方显示UserForm?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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