Userform停止其他工作表滚动

时间:2017-06-14 20:41:14

标签: excel vba excel-vba

我有一些用户表单。一个是显示说明的弹出窗口,另一个是输入数量。问题是当我点击一个并关闭它(每个关闭Unload Me)然后当我用sht.Activate宏按钮切换工作表时,工作表不会滚动。看起来这张纸被冷冻了。我可以通过加载用户窗体并在当前工作表上再次关闭它来解决问题,然后解冻"解冻"表。

知道为什么会这样吗?

  

用户窗体

Private Sub UserForm_Click()
Unload Me
End Sub

以下是我如何通过按钮调用它。

Sub Instructions()
With UserFormInstructions
    .StartUpPosition = 0
    .Left = Application.Left + (0.5 * Application.Width) - (0.5 * .Width)
    .Top = Application.Top + (0.5 * Application.Height) - (0.5 * .Height)
    .Show
End With
End Sub
  

表格按钮

Sub goto630()
Application.ScreenUpdating = False

Dim sht2 As Worksheet
Set sht2 = ThisWorkbook.Worksheets("Foundation Plates")
Dim sht3 As Worksheet
Set sht3 = ThisWorkbook.Worksheets("630 BOM")

sht3.Activate
sht3.Unprotect

sht2.Visible = True
sht3.Visible = True

On Error GoTo 0

    ActiveWindow.Zoom = 90
    ActiveWindow.DisplayHeadings = True
    ActiveWindow.DisplayHorizontalScrollBar = True
    ActiveWindow.DisplayVerticalScrollBar = True
    Application.DisplayFormulaBar = True
    sht3.DisplayPageBreaks = False

sht2.Protect
sht3.Protect _
        DrawingObjects:=False, _
        Contents:=True, _
        Scenarios:=False, _
        UserInterFaceOnly:=False, _
        AllowFormattingCells:=True
Call NoSelect

Set sht3 = Nothing
Application.ScreenUpdating = True
End Sub

Sub NoSelect()
Application.ScreenUpdating = False

    Range("D1").Select
    ActiveWindow.SmallScroll ToLeft:=4

Application.ScreenUpdating = True
End Sub

由于

0 个答案:

没有答案