excelvbauserform

Activate worksheet from its userform


I am trying to activate, from the clicking of a userform button, the worksheet where the form is located:

ThisWorksheet

I have tried the following commands, but none of them worked as expected (using windows 11 and excel 365):

Private Sub CommandButton1_Click()
    Excel.ActiveCell.Activate
    Application.Windows(1).Activate
    ActiveWindow.Activate
    ActiveCell.Select
    ActiveCell.Activate
End Sub

Is it possible to activate the worksheet from clicking userform button.? If so, how? Thanks.


Solution

  • From: Application.SendKeys Keys:="{F2}" does not work from Form button subroutine

    Private Sub CommandButton1_Click()
        Appactivate Thisworkbook.Name
        EditActiveCell
    End Sub
    
    Sub EditActiveCell()
        Selection.Activate
        Application.SendKeys "{F2}", True
    End Sub