Search code examples
excelvbaoffsetuserformcommandbutton

Method or Data member not found User Form


Command Button Shapes I have created this Command Button Shapes For User Form which looks like. User Form It has different codes for borders. When I click UserForm Command Button. It throws me this error. Error

Can Someone tell where I am wrong?

First Edit:

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

Solution

  • So I figured it out Shape Command Button Code.

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

    And UserForm Code

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