未找到方法或数据成员用户窗体

Method or Data member not found User Form

Command Button Shapes 我已经为用户表单创建了这个命令按钮形状,它看起来像。 User Form 它有不同的边界代码。 当我单击用户窗体命令按钮时。它抛出这个错误。 Error

谁能告诉我哪里错了?

第一次编辑:

Private Sub CommandButton1_Click()
Dim rng As Range
    Me.CommandButton1.TopLeftCell.Offset(1, -2).Select
    Set rng = ActiveSheet.Range("Me.CommandButton1.TopLeftCell.Offset(1, -2)")
    rng.Borders.LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
    Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
    Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
    UserForm2.Hide
End Sub

所以我想出了形状命令按钮代码。

Private Sub CommandButton1_Click()
Me.CommandButton1.TopLeftCell.Offset(1, -2).Select
UserForm2.Show
End Sub

和用户表单代码

ActiveCell.Borders.LineStyle = xlNone
    Selection.Borders(xlEdgeTop).LineStyle = xlContinuous
    Selection.Borders(xlEdgeLeft).LineStyle = xlContinuous
    Selection.Borders(xlEdgeRight).LineStyle = xlContinuous
    UserForm2.Hide