ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy Push Button and VB Functionality (https://www.excelbanter.com/excel-programming/373909-copy-push-button-vbulletin-functionality.html)

SystemParametersInfo -Kokomo

Copy Push Button and VB Functionality
 
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

Tom Ogilvy

Copy Push Button and VB Functionality
 
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.

--
Regards,
Tom Ogilvy


"SystemParametersInfo -Kokomo" wrote:

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


SystemParametersInfo -Kokomo

Copy Push Button and VB Functionality
 
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.

"Tom Ogilvy" wrote:

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.

--
Regards,
Tom Ogilvy


"SystemParametersInfo -Kokomo" wrote:

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


SystemParametersInfo -Kokomo

Copy Push Button and VB Functionality
 
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.

"SystemParametersInfo -Kokomo" wrote:

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.

"Tom Ogilvy" wrote:

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.

--
Regards,
Tom Ogilvy


"SystemParametersInfo -Kokomo" wrote:

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



All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com