View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Building Forms (like a command button) into a cell

Hi John,

Here's an example

Sub AddFormsButton()
Dim cell As Range
Dim oBtn

With ActiveSheet
For Each cell In Range("B5:B10")
Set oBtn = .Buttons.Add(cell.Left, cell.Top, cell.Width,
cell.Height)
oBtn.Caption = "Button " & cell.Row
oBtn.OnAction = "Macro1"
Next cell
End With

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"John Keith" wrote in message
...
Is there an easy way to create a series of command buttons programatically

so
that they line up in a column of cells. Each button will need to be

renamed,
each cell (that gets a button) will need to be sized properly. I would

like
to know if there is an option that would do this... the only other way I

can
think of that might work is to figure out how to calculate the necessary

size
for each cell based on the top-left and bottom-right cords of the button.

I also will need to do the same kind of function for a picture-box and
assign a formula to this (using it as a view window to show a series of

cells
from another part of the workbook)

Both of these will also include a block copy with a range of cells and

their
formulae. (If there were a way to do the cell copy [which includes 1

picture
box & 1 button] and have it include the objects ... and be able to rename

the
objects and set the new formula or macro, this would accomplish the task)

Any tips on how to approach this?

--
Regards,
John