Copy Push Button and VB Functionality

G

Guest

I am new to using VB with excel, so please be gental. I am trying to
duplicat a push button that was created for one row of cells. I want all
other rows of cells to have their own push buton with the same funcationality
only using the data from their row and output to their row. How can this be
done without creating each buttno and its VB code from scratch?

Like when you select a funtion and copy it to other cells. The function is
moved and then the cells that it is usnign are updated with the move.

Is there a way to attach a Push Button to a cell and then have the cells
location as an input parameter to the VB init?

Thanks,
Jeff
 
G

Guest

if you use a push button from the forms toolbar, you can assign a single
macro to each button.

Public Sub pButton_Click()
Dim rng as Range, rw as Long
Dim sName as String, btn as Button
sName = Application.Caller
set btn = Activesheet.buttons(sname)
set rng = btn.TopLeftCell ' or .BottomRightCell
rw = rng.row
msgbox sname & ": " & rng.Address(0,0)
End Sub

as an example.
 
G

Guest

Thanks Tom,

But how can I call my VB code from there? My current button opens a dialog
box that will then open different forms based on the users selection.
 
G

Guest

Oh man...I did not see it at first. Now I get it. I will dig in further,
but it looks like this might work for me. 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

Top