ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   same button on multiple pages (https://www.excelbanter.com/excel-programming/436116-same-button-multiple-pages.html)

robin

same button on multiple pages
 
Hi
I have a multipage form and I would like to know if it's possible to link
the "on click" code to similar buttons on the different pages. For example,
on each form, I have a NEXT button which takes you to the next page. I would
like to know if the same code can be assigned to each NEXT button, instead of
having many different CommandButtonxx_click codes. It would be great to just
refer each button to say a cbNext_click() code.
Thanks!

joel

same button on multiple pages
 
You need to have one macro for each button. but you can combine the code if
you are smart

Private Sub CommandButton1_Click()
call Commonbutton()
End Sub

Private Sub CommandButton1_Click()
call Commonbutton()

End Sub

Private Sub CommandButton1_Click()
call Commonbutton()

End Sub

'put into a module
Sub Commonbutton()

'put common code here
exit Sub


"Robin" wrote:

Hi
I have a multipage form and I would like to know if it's possible to link
the "on click" code to similar buttons on the different pages. For example,
on each form, I have a NEXT button which takes you to the next page. I would
like to know if the same code can be assigned to each NEXT button, instead of
having many different CommandButtonxx_click codes. It would be great to just
refer each button to say a cbNext_click() code.
Thanks!


Dave Peterson

same button on multiple pages
 
On most of these type wizards, the back and next buttons are outside of the
multipage control. (Look at how the data|text to columns wizard is laid out.)



Robin wrote:

Hi
I have a multipage form and I would like to know if it's possible to link
the "on click" code to similar buttons on the different pages. For example,
on each form, I have a NEXT button which takes you to the next page. I would
like to know if the same code can be assigned to each NEXT button, instead of
having many different CommandButtonxx_click codes. It would be great to just
refer each button to say a cbNext_click() code.
Thanks!


--

Dave Peterson


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

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