Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Adding a Button

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Adding a Button

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

--
Regards,
Tom Ogilvy



" wrote:

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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Adding a Button

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a Button Bob Barnes Excel Discussion (Misc queries) 2 June 30th 08 07:36 PM
Adding a button with Add-in Eric[_20_] Excel Programming 2 February 21st 07 07:53 PM
Adding .xla button for Toggle Calculation Button Mike Excel Programming 5 August 19th 05 01:55 PM
Adding a button pauluk[_12_] Excel Programming 1 March 3rd 04 06:28 PM
adding button for add-in Tom Ogilvy Excel Programming 1 October 1st 03 11:23 PM


All times are GMT +1. The time now is 06:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"