Created
July 2, 2015 14:03
-
-
Save DouglasdeMoura/82ac2c27c471d9f3d35a to your computer and use it in GitHub Desktop.
Create a button on Excel spreasheets with VBA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Usage: | |
' Call CreateButton("Example", "A1", "name_of_the_macro") | |
Sub CreateButton(name, rng, theMacro) | |
With ActiveSheet | |
Debug.Print .range(rng).Left | |
Debug.Print .range(rng).Top | |
.Buttons.Add(.range(rng).Left, .range(rng).Top, .range(rng).Width, .range(rng).height).Select | |
With Selection | |
.Characters.Text = name | |
.OnAction = theMacro | |
.name = name & rng | |
End With | |
End With | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment