Steven
Steven

Reputation: 1183

Excel VBA change button size and location

How do I change a button size and location on an excel sheet?

Upvotes: 6

Views: 49972

Answers (2)

chris neilsen
chris neilsen

Reputation: 53126

You are almost there with ActiveSheet.Shapes("Button 1")

If you dim a variable as Shape and assign the button to it, you can use intellisence to explore the available properties. From there you will find .Height, .Width, .Left, .Top

Dim btn As Shape
Set btn = ActiveSheet.Shapes("Button 1")
btn.Height = 50
btn.Width = 100

Upvotes: 10

PowerUser
PowerUser

Reputation: 11781

Steven, to learn basic VBA in Excel, I recommend experimenting with the Record Macro option. It's location varies depending on your version of Excel (In 2007, you need to activate the Developer tab in your ribbon).

With this button turned on, use the standard menus to do whatever you wanted to do in the first place (in this case, make a custom sized button). Then stop the recording and look at the auto-generated code you just made.

Upvotes: 0

Related Questions