LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Put a button in a cell

Try this against a copy of your worksheet--just in case:

Option Explicit
Sub AddButtons()

Dim myRng As Range
Dim myCell As Range
Dim wks As Worksheet
Dim myBTN As Button

Set wks = ActiveSheet
With wks
.Buttons.Delete 'remove existing buttons???
Set myRng = .Range("a1:a10")
For Each myCell In myRng.Cells
With myCell
Set myBTN = .Parent.Buttons.Add _
(Height:=.Height, _
Width:=.Width, _
Left:=.Left, _
Top:=.Top)
myBTN.Name = "BTN_" & .Address(0, 0)
myBTN.OnAction = ThisWorkbook.Name & "!myBTNmacro"
myBTN.Caption = "Click Me"
End With
Next myCell
End With
End Sub
Sub myBTNMacro()
Dim myBTN As Button

Set myBTN = ActiveSheet.Buttons(Application.Caller)
With myBTN
.TopLeftCell.EntireRow.Delete
.Delete
End With

End Sub



Christopher Benson-Manica wrote:

Michael Malinsky spoke thus:

Put the button where you want it then, while in design mode, right-click the
button and select Format Control. On the Properties tab, select "Don't move
or size with cells" to cause to button to remain in position regardless of
the adding or deleting of cells.


Hm... I guess my original post wasn't really clear. I need a button
(or something else!) that fits inside a cell completely and deletes
the row it's on (as well as itself) when clicked. It needs to be
inside a cell, because I want one of these for each row on a
worksheet, including rows not currently visible... I appreciate your
help, and I hope I'm being more clear this time. :)

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.


--

Dave Peterson
 
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
Can I add button to cell to easily view all data in cell? Geekwanabe Excel Discussion (Misc queries) 1 February 26th 09 05:39 PM
Transfer cell values to another cell by selecting button. Gryndar Excel Worksheet Functions 2 November 24th 08 02:21 AM
Excel - create button to replace cell content with cell value blackmot Excel Worksheet Functions 3 December 7th 05 05:10 PM
Control Cell Link for Option Button based on value in a cell arunjoshi[_14_] Excel Programming 1 May 5th 04 02:19 AM
Control Cell Link for Option Button based on value in a cell arunjoshi[_13_] Excel Programming 0 May 4th 04 05:46 AM


All times are GMT +1. The time now is 08:26 AM.

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"