简体   繁体   English

在Excel 2010中使用vba从用户窗体返回“突出显示”到工作表

[英]return “highlight” from userform to worksheet with vba in excel 2010

I have a worksheet and a userform shown in vbModeless mode, as I need it to be visible all the time. 我有一个工作表和一个以vbModeless模式显示的用户窗体,因为我希望它始终可见。 The userform includes a button. 该用户窗体包含一个按钮。 This button does a specific job, depending on the current selected cell at the worksheet. 此按钮执行特定的工作,具体取决于工作表上当前选择的单元格。 After pressing the button, highlight stays at the userform. 按下按钮后,突出显示停留在用户窗体上。

What I need is, after pressing the button, highlight to return at the worksheet and be able to scroll at the worksheet or use the arrows (keyboard), without having to clic at the worksheet first. 我需要的是,在按下按钮后,突出显示以返回工作表,并能够在工作表上滚动或使用箭头(键盘),而不必先手动查看工作表。 I tried this: 我尝试了这个:

Private Sub CommandButton1_Click()
    ...
    Worksheets(1).Activate
End Sub

but it doesn't do what I want. 但这并不能满足我的要求。 I also tried the recorder but I got an error. 我也尝试了录音机,但出现错误。 What's the code for doing this? 这样做的代码是什么?

这个怎么样:

AppActivate Application.Caption

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM