ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How can I reuse function for a userform button (https://www.excelbanter.com/excel-programming/400313-how-can-i-reuse-function-userform-button.html)

axwack

How can I reuse function for a userform button
 
I have move up and move down buttons that move data lists up and down
on a list box.

The buttons are repeated on different tabs of the same form.

I want to pass a reference of the button ("Move Up") to my move up
code. How can I send a generic reference of a control to a function?

Is it

private sub function (Button as Control)

do code

end Sub

Any help is appreciated.


Bob Phillips

How can I reuse function for a userform button
 
Private Sub cmdOK_Click()
Call myFunc(Me.cmdOK)
Me.Hide
End Sub

Private Function myFunc(btn As MSForms.CommandButton)
MsgBox btn.Name
End Function


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"axwack" wrote in message
ups.com...
I have move up and move down buttons that move data lists up and down
on a list box.

The buttons are repeated on different tabs of the same form.

I want to pass a reference of the button ("Move Up") to my move up
code. How can I send a generic reference of a control to a function?

Is it

private sub function (Button as Control)

do code

end Sub

Any help is appreciated.





All times are GMT +1. The time now is 06:33 AM.

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