How to use a Command Button inserted in the Spreadsheet in the VBA code?

Asked

Viewed 3,061 times

2

I have a command button that I inserted in a spreadsheet, and wanted to know which function I have to assign in vba code, to know when a user clicks on it !

3 answers

2

On the click counter, you can make it disappear into any cell when the user clicks on the button. For example:

Sub Button1_Click()

Sheet1.Cells(1, 1).Value = Sheet1.Cells(1, 1).Value + 1

End Sub

Surely you will find more effective ways to do this, but this is the simplest as far as I know!

1


  1. If it is an Active-x button Active-X controls double-click on the button and it will open in VBA a Sub to create your code.

  2. If it’s a common button Form Controls, you can create your macro and then right click on the button, select the option Assign macro..., select your macro and you will have your button running the function you want.

I hope I’ve helped!

1

Good morning,

I was able to solve, using the Activex button, when someone clicks on it I assigned a variable that enables a specific worksheet.

Thank you all for your cooperation.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.