![]() |
Commandbar - how to find out which msoCommandButton was pressed
I have own CommandBar "MyMenu" with three msoCommandButton. Each
CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
Commandbar - how to find out which msoCommandButton was pressed
Parameter is what you're after.
I have CommandBar Button examples on my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
Commandbar - how to find out which msoCommandButton was pressed
Try again... post seems to delete itself from the server.
--- Parameter is what you're after. I have CommandBar Button examples on my website. -- Rob van Gelder - http://www.vangelder.co.nz/excel "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
Commandbar - how to find out which msoCommandButton was pressed
Hi Joseph;
Select Case Application.Caller(1) Case 1 '... case 2 '... Case 3 '... End Select MP "JosephVBA" a écrit dans le message de ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
Commandbar - how to find out which msoCommandButton was presse
Thanks, it seems like a good solution. I`ll try it later.
|
Commandbar - how to find out which msoCommandButton was pressed
I think the best answer is
set cb = CommandBars.ActionControl If you need a case statement you could use Userform1.Load Select Case cb.Caption Case "Button1" Userform1.Listbox1.RowSource = "Sheet1!A1:A10" Case "Button2" Userform1.Listbox1.RowSource = "Sheet1!B1:B10" End Select Userform1.Show -- Regards, Tom Ogilvy "JosephVBA" wrote in message ... I have own CommandBar "MyMenu" with three msoCommandButton. Each CommandButton runs the macro, I change only the rowsource for UserForm. E.g. CommandButton(1) runs MyMacro1 with setting the rowsource="range1", CommandButton(2) runs MyMacro2 with setting the rowsource="range2". I have for each CommandButton own macro. Is some way how to find out which CommandButton was pressed and this argument I can use in next code. myPressButton = 'which CommandButton was pressed ' Sub MyMacroAll Select Case myPressButton Case ?: UserForm1.rowsource = "range1" Case ??: UserForm1.rowsource = "range2" End Select End Sub |
All times are GMT +1. The time now is 05:22 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com