6

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

2
  • The only thing that I found is adding a button. I also found ActiveSheet.Shapes("Button 1") but did not get it to work. Commented Oct 31, 2011 at 20:30
  • 4
    Why was this post down-voted? If you are going to down-vote someone, please explain your reasoning. That's why we're all here: to learn from each other. Commented Oct 31, 2011 at 20:52

2 Answers 2

10

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
Sign up to request clarification or add additional context in comments.

2 Comments

The units of the height and width measurement are in points. learn.microsoft.com/en-us/office/vba/api/…
More details about points, twips and millimetres davetallett26.github.io/makeform.html
0

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.

2 Comments

Excellent tip, but all I see on record macro is .ScaleWidth and not .Width
You are correct. I had to try it for myself. For some reason the macro recorder only records commands for scaling the button's size. It doesn't record absolute changes in the size. Please use @chris neilsen's answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.