如何创建一个宏以导航到另一个工作表

时间:2019-06-21 12:15:31

标签: excel vba

我正在尝试返回到宏页面;但是,我收到运行时错误。

Sub OpenMenu()

    Sheets("Macros").Select

Dim PS As Positions

    #If VBA6 Then
        Dim HO As cstFormHorizontalPosition
        Dim VO As cstFormVerticalPosition
    #Else
        Dim HO As Long
        Dim VO As Long
    #End If


    HO = cstFhpFormLeftCellLeft '   set these to how you want the form positioned relative to AnchorCell
    VO = cstFvpFormBottomCellCenter '   set these to how you want the form positioned relative to AnchorCell


    '
    ' Call PositionForm to determine the correct positions
    '
    PS = PositionForm(WhatForm:=frmSelectReport, AnchorRange:=Range("B1"), HorizOrientation:=HO, VertOrientation:=VO)
    frmSelectReport.Top = PS.FrmTop   ' set the Top position of the form
    frmSelectReport.Left = PS.FrmLeft ' set the Left position of the form
    frmSelectReport.Show

End Sub

错误出现在PS = PositionForm(WhatForm:=frmSelectReport, AnchorRange:=Range("B1"), HorizOrientation:=HO, VertOrientation:=VO)

0 个答案:

没有答案