Adding a Button

  • Thread starter Thread starter bgetson
  • Start date Start date
B

bgetson

How can I add a button {from form controls} to the active sheet if I
want it to be in a specific position? Ideally, I want the button to be
aligned in one row and contained between three columns - my problem is
that I won't know before hand which row I want to restrict by.

The sheet I'm dealing with will have a variable amount of data every
time it is generated by my code, and I always want the button to be at
the end of the data.

Any ideas?
-bgetson
 
something along these lines:

Sub AD()
With Cells(Cells(Rows.Count, 1).End(xlUp).Row, 10)
Set btn = ActiveSheet.Buttons.Add( _
Left:=.Left, _
Top:=.Top, _
Width:=.Resize(1, 3).Width, _
Height:=.Height)
End With
btn.OnAction = "MyMacro"
End Sub
 
Thank you so much for your help. To be honest, when I'd asked for
help, I'd basically resigned myself to reformatting everything so that
my buttons were on top and everything else displayed underneath. The
code you provided works perfectly, and I can easily get it to work for
my project.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top