在worksheets.activate命令之后的非活动列表框
我的ActiveX控件列表框有问题。 在worksheets.activate命令之后,它似乎处于不活动状态。
这是我在做什么:
-
在Sheet1中,我有两个button来触发不同的vba代码和一个ActiveX控件列表框,用于生成第二次计算所需的string。 当我将鼠标移动到列表框上时,光标从十字转到箭头,所以我可以select这些框。
-
我的第一个button触发一个基于vba的数据导入。 数据存储在Sheet2中。 之后,我再次激活Sheet1(Sheet1.Activate)。 之后,不再可能selectListBox中的框(当在列表框上移动时,光标不再从十字转换为箭头)。
如果我摆脱命令Sheet1.Activate,在数据导入后,ActiveSheet显然是Sheet2。 奇怪的是,在Excel中selectSheet1后,ListBox仍然在工作。 所以在我看来,命令worksheets.activate以某种方式停用列表框。 有没有人有一个想法如何解决这个问题?
这将是导入脚本的代码:
Sub import_stuff() ''defining variables Dim panel As Worksheet ''turn off screen updating and displaying alerts Application.ScreenUpdating = False Application.DisplayAlerts = False ''defining the used workbooks Set panel = ThisWorkbook.Worksheets("Controll Panel") Set inputbook = Workbooks.Open("link to file") ''delete the worksheet "input data" if it exists, if not it does nothing... On Error Resume Next thisbook.Worksheets("Input data").Delete On Error GoTo 0 ''copying the data from the source file to a new worksheet inputbook.Worksheets("Sheet1").copy After:=panel ''renaming the newly generated worksheet ActiveSheet.name = "Input data" ''closing the source file without saving inputbook.Close False panel.Activate Application.ScreenUpdating = True Application.DisplayAlerts = True End Sub
提前致谢!