locked
Use Excel Cell as button in VBA Programming RRS feed

  • Question

  • Hi

    In Microsoft Excel VBA, can we use one cell as Button? by Fixing cell position and also able to assign macro to particular call? 

    Thanks.

    Friday, September 1, 2017 12:27 PM

Answers

  • In Microsoft Excel VBA, can we use one cell as Button?

    No.

    You can use the SelectionChange event to get noticed if the user select a different cell (and run a code, sample below).

    But once the "button" cell is selected, the user must select an other cell and then your "button" cell again to run the same code. A real button could be clicked 2 times in a row.

    Andreas.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
      Select Case Target.Address(0, 0)
        Case "A1"
          MsgBox "Hello World"
      End Select
    End Sub

    Friday, September 1, 2017 3:09 PM